Documentation
¶
Overview ¶
Package sqlite is a durable, single-node queue backend built on database/sql + SQLite. Messages survive process restart. Delivery is at-least-once: a subscriber claims a message, and only DELETEs it after the handler returns nil.
Consumers must blank-import their SQLite driver (typically modernc.org/sqlite). This package uses only database/sql.
The schema lives in schema.sql (embedded). Call Init once on a fresh database to create the tables.
SQLite pool notes ¶
SQLite has two footguns that hex/queue/sqlite consumers should know about:
- :memory: databases are per-connection. If the *sql.DB pool holds more than one connection, Init runs against one and Publish/Subscribe may land on another that has no schema. Use MaxOpenConns: 1 with :memory:.
- File-backed databases with concurrent writers hit SQLITE_BUSY unless WAL mode and a busy_timeout are enabled. Configure the DSN accordingly: "file:queue.db?_pragma=journal_mode(WAL)&_pragma=busy_timeout(5000)".
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Options ¶
type Options struct {
// PollInterval is how often subscribers scan for new messages.
// Defaults to 200ms. Tune down for lower latency, up for lower load.
PollInterval time.Duration
// MaxRetries caps redelivery attempts. Zero means unlimited. Callers
// wanting DLQ should use the hex/queue/jobs layer.
MaxRetries int
// RetryDelay is the wait before a failed message is redelivered.
// Zero means immediate.
RetryDelay time.Duration
// VisibilityTimeout is how long a claimed message stays hidden from
// other consumers before being made visible again (assumed
// crashed). Defaults to 30 seconds.
VisibilityTimeout time.Duration
}
Options tune a sqlite Queue.
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue is the sqlite-backed implementation of queue.Queue.
func New ¶
New returns a sqlite Queue backed by db. The database must already contain the queue schema (call Init).
func (*Queue) Close ¶
Close stops all subscribers and closes the underlying DB is left to the caller (hex/db semantics — caller owns *sql.DB).