https://github.com/nickalie/go-queue
Multi backend queues for Golang
https://github.com/nickalie/go-queue
distributed-systems golang queue
Last synced: 5 months ago
JSON representation
Multi backend queues for Golang
- Host: GitHub
- URL: https://github.com/nickalie/go-queue
- Owner: nickalie
- License: mit
- Created: 2017-04-25T17:24:34.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-08-06T12:14:14.000Z (almost 8 years ago)
- Last Synced: 2024-06-19T04:21:22.976Z (almost 2 years ago)
- Topics: distributed-systems, golang, queue
- Language: Go
- Size: 28.3 KB
- Stars: 19
- Watchers: 4
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Go Queue
Multi backend queues for Golang
[](https://godoc.org/github.com/nickalie/go-queue)
[](https://circleci.com/gh/nickalie/go-queue)
[](https://codecov.io/gh/nickalie/go-queue)
[](https://www.codacy.com/app/nickalie/go-queue?utm_source=github.com&utm_medium=referral&utm_content=nickalie/go-queue&utm_campaign=Badge_Grade)[](https://goreportcard.com/report/github.com/nickalie/go-queue)
## Install
```go get -u github.com/nickalie/go-queue```
## Example of usage
```go
package main
import (
"fmt"
"github.com/nickalie/go-queue"
"time"
)
func main() {
for i := 0; i < 5; i++ {
go consumer(i + 1)
}
producer()
}
func producer() {
i := 0
for {
i++
queue.Put("messages", fmt.Sprintf("message %d", i))
time.Sleep(time.Second)
}
}
func consumer(index int) {
for {
var message string
queue.Get("messages", &message)
fmt.Printf("Consumer %d got a message: %s\n", index, message)
time.Sleep(2 * time.Second)
}
}
```