gopq: Go Persistent-Queue

A lightweight, sqlite-backed persistent queue implementation in Go

Go Database Concurrency Data Structures
View Project

gopq: Go Persistent-Queue

gopq is a lightweight, persistent queue implementation in Go, using SQLite as the underlying storage mechanism. It provides various queue types to suit different use cases, including simple queues, acknowledged queues, and unique item queues.

Key Features

  • Persistent storage using SQLite
  • Multiple queue types: Simple, Acknowledged, Unique, and Unique-Acknowledged
  • Blocking and non-blocking operations
  • Context support for cancellation and timeouts
  • Thread-safe operations
  • Configurable dead letter queues

Quick Example

go
package main
import (
"fmt"
"github.com/mattdeak/gopq"
)
func main() {
// Create a new simple queue
queue, err := gopq.NewSimpleQueue("myqueue.db")
if err != nil {
panic(err)
}
defer queue.Close()
// Enqueue an item
err = queue.Enqueue([]byte("Hello, gopq!"))
if err != nil {
panic(err)
}
// Dequeue an item
msg, err := queue.Dequeue()
if err != nil {
panic(err)
}
fmt.Println(string(msg.Item)) // Output: Hello, gopq!
}

Why Use gopq?

gopq is ideal for applications that require durable, persistent queues with various reliability guarantees. It’s particularly useful in scenarios where you need:

  1. Data persistence across application restarts
  2. Guaranteed message processing with acknowledgments
  3. Deduplication of queue items
  4. Flexible queue behaviors to suit different use cases

Whether you’re building a task queue, a message broker, or any system that requires reliable, persistent queuing, gopq provides a solid foundation with a simple, idiomatic Go API.

For more detailed information, usage examples, and API documentation, check out the GitHub repository.