Skip to content

nickalie/go-queue

Repository files navigation

Go Queue

Multi backend queues for Golang

codecov Codacy BadgeGo Report Card

Install

go get -u github.com/nickalie/go-queue

Example of usage

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)
	}
}

About

Multi backend queues for Golang

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages