Categorygithub.com/semihbkgr/go-rsmq
modulepackage
1.3.1
Repository: https://github.com/semihbkgr/go-rsmq.git
Documentation: pkg.go.dev

# README

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.

# Packages

No description provided by the author

# Functions

NewRedisSMQ creates and returns new rsmq client.

# Constants

Unset values are the special values to refer default values of the attributes.
Unset values are the special values to refer default values of the attributes.
Unset values are the special values to refer default values of the attributes.

# Variables

Validation errors.
Validation errors.
Validation errors.
Validation errors.
Validation errors.
Errors returned on rsmq operation.
Errors returned on rsmq operation.
Errors returned on rsmq operation.
Errors returned on rsmq operation.

# Structs

QueueAttributes contains some attributes and stats of queue.
QueueMessage contains content and metadata of message received from queue.
RedisSMQ is the client of rsmq to execute queue and message operations.