work-pebblequeue
An implementation of the Queue interface from github:taylorchu/work for pebble.
Usage
func main() {
db, err := pebble.Open("pebble_test", &pebble.Options{})
if err != nil {
t.Fatal(err)
}
defer db.Close()
queue := work.NewPebbleQueue(db)
job := work.NewJob()
type message struct {
Text string
}
job := work.NewJob()
err = job.MarshalPayload(message{Text: "hello"})
if err != nil {
log.Fatalln(err)
}
err = queue.Enqueue(job, &work.EnqueueOptions{
Namespace: "{ns1}",
QueueID: "cmd_queue",
})
if err != nil {
log.Fatalln(err)
}
}
Caveats
Don't use multiple proccesses to connect to the same databese. Pebble is not designed for that. If you need to use multiple processes, use a different database. In the case of using this package, it is expected that the producer and consumer are sharing the same pebble "connection", and are goroutines in the same procecss.
License
This project is a largely based on the existing redis queue implementation in work, which is licensed under the MIT license, so this project is also licensed under the MIT license to ensure compliance. A very big thank you to Taylor Chu for their work (no pun intended) on work.
You can see work, and it's documentation here: https://github.com/taylorchu/work