Help us shape the future of Go! Take the 2026 Go Developer Survey

sqlite

package
v0.11.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package sqlite provides a durable, embedded queue.Service backed by SQLite.

Use it with any database/sql SQLite driver (modernc.org/sqlite, mattn/go-sqlite3).

SQLite has no FOR UPDATE SKIP LOCKED. Claim queries run inside a BEGIN IMMEDIATE transaction; concurrent claimers serialize on the database write lock. This is fine for embedded single-process workloads. For high throughput across many processes, use the pgx backend instead.

The database is opened in WAL mode (PRAGMA journal_mode=WAL; PRAGMA synchronous=NORMAL) for adequate write throughput. The caller is responsible for opening the *sql.DB; queue/sqlite does not own connection lifetime.

Index

Constants

This section is empty.

Variables

View Source
var Schema string

Functions

func Apply

func Apply(ctx context.Context, db *sql.DB) error

Apply executes the embedded schema against db. Idempotent — uses CREATE TABLE IF NOT EXISTS.

Types

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is the SQLite queue implementation.

func New

func New(db *sql.DB, opts ...queue.QueueOption) *Service

New constructs a SQLite queue.Service. The caller owns db.

func (*Service) Close

func (s *Service) Close(_ context.Context) error

Close shuts down all consumers.

func (*Service) Enqueue

func (s *Service) Enqueue(ctx context.Context, topicName string, payload []byte, opts ...queue.EnqueueOption) error

Enqueue inserts a job into queue_jobs.

func (*Service) Subscribe

func (s *Service) Subscribe(ctx context.Context, topicName string, h queue.Handler, opts ...queue.SubscribeOption) (queue.Consumer, error)

Subscribe spawns a worker pool that polls + reacts to local enqueue signals.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL