Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kavehmz/queue
A Go queue manager on top of Redis
https://github.com/kavehmz/queue
golang queue redis
Last synced: about 1 month ago
JSON representation
A Go queue manager on top of Redis
- Host: GitHub
- URL: https://github.com/kavehmz/queue
- Owner: kavehmz
- License: mit
- Created: 2015-11-30T10:32:14.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2021-09-05T17:05:08.000Z (about 3 years ago)
- Last Synced: 2024-09-29T13:40:59.112Z (about 2 months ago)
- Topics: golang, queue, redis
- Language: Go
- Size: 30.3 KB
- Stars: 74
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Queue
=========
[![Go Lang](http://kavehmz.github.io/static/gopher/gopher-front.svg)](https://golang.org/)
[![GoDoc](https://godoc.org/github.com/kavehmz/queue?status.svg)](https://godoc.org/github.com/kavehmz/queue)
![Build Status](https://github.com/kavehmz/queue/actions/workflows/go.yml/badge.svg?branch=master)
[![Coverage Status](https://coveralls.io/repos/kavehmz/queue/badge.svg?branch=master&service=github)](https://coveralls.io/github/kavehmz/queue?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/kavehmz/queue)](https://goreportcard.com/report/github.com/kavehmz/queue)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/kavehmz/queue)A [Go](http://golang.org) library for managing queues on top of Redis.
It is based on a hiring exercise but later I found it useful for myself in a custom task processing project.
I thought it might be useful in general.## Installation
```bash
$ go get github.com/kavehmz/queue
```# Usage
```go
package mainimport (
"fmt"
"time""github.com/kavehmz/queue"
)func main() {
var q queue.Queue
q.Urls([]string{"redis://localhost:6379"})
q.AddTask(1, "start")
q.AddTask(2, "start")
q.AddTask(1, "stop")
q.AddTask(2, "stop")
analyzer := func(id int, task chan string, success chan bool) {
for {
select {
case msg := <-task:
fmt.Println(id, msg)
if msg == "stop" {
success <- true
return
}
case <-time.After(2 * time.Second):
fmt.Println("no new events for 2 seconds for ID", id)
success <- false
return
}
}
}
exitOnEmpty := func() bool {
return true
}
q.AnalysePool(1, exitOnEmpty, analyzer)
}
```## Approach
Focus of this design is mainly horizontal scalability via concurrency, partitioning and fault-detection.