Skip to content

A lightweight message queue for Go that requires no dedicated queue server.

License

Notifications You must be signed in to change notification settings

semihbkgr/go-rsmq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-rsmq

CI workflow Codecov Go Reference

A lightweight message queue for Go that requires no dedicated queue server. Just a Redis server.

Go implementation of https://github.com/smrchy/rsmq.

$ go get github.com/semihbkgr/go-rsmq

Redis Simple Message Queue

If you run a Redis server and currently use Amazon SQS or a similar message queue you might as well use this fast little replacement. Using a shared Redis server multiple Go processes can send / receive messages.

Example

opts := &redis.Options{Addr: "localhost:6379"}
redisClient := redis.NewClient(opts)

rsmqClient := rsmq.NewRedisSMQ(redisClient, "rsmq")
defer rsmqClient.Quit()

err := rsmqClient.CreateQueue("queue", rsmq.UnsetVt, rsmq.UnsetDelay, rsmq.UnsetMaxsize)
if err != nil {
    fmt.Println(err.Error())
}

id, err := rsmqClient.SendMessage("queue", "message", rsmq.UnsetVt)
if err != nil {
    panic(err)
}
fmt.Printf("message sent, id: %s\n", id)

msg, err := rsmqClient.PopMessage("queue")
if err != nil {
    panic(err)
}
if msg == nil {
    fmt.Println("queue is empty")
} else {
    fmt.Printf("message received, id: %s, message: %s", msg.ID, msg.Message)
}

Producer/Consumer example

Implementation Notes

All details about the queue implementation are in here.

go-rsmq follows all the naming conventions of javascript implementation.

About

A lightweight message queue for Go that requires no dedicated queue server.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages