sqlite

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package sqlite provides a SQLite implementation of outbox.Store using database/sql. Use it with any SQLite database/sql driver (mattn/go-sqlite3, modernc.org/sqlite, etc.).

SQLite has no FOR UPDATE SKIP LOCKED. FetchPending wraps the claim in a short transaction; concurrent workers serialize on the database write lock, which is fine for most outbox workloads but does not scale to many parallel claimers the way PostgreSQL does.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTableSQL

func CreateTableSQL(tableName string) string

CreateTableSQL returns the SQLite DDL for creating the outbox messages table.

SQLite has no native UUID, JSON or bytea types — TEXT/BLOB are used instead and IDs are generated by the Store on insert. The partial index requires SQLite 3.8 or newer.

func Migrate

func Migrate(ctx context.Context, db osql.Execer, tableName string) error

Migrate creates the outbox messages table if it does not exist. db can be a *sql.DB, *sql.Tx, *sql.Conn or any other type implementing osql.Execer.

Types

type Store

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

Store implements outbox.Store for SQLite.

func New

func New(db *stdsql.DB, options ...osql.Option) *Store

New creates a new SQLite outbox store backed by *sql.DB.

func (*Store) FetchPending

func (s *Store) FetchPending(ctx context.Context, limit int) ([]outbox.Message, error)

FetchPending atomically claims up to limit pending messages for processing. Wrapped in a transaction so the SELECT and UPDATE see a consistent snapshot.

func (*Store) MarkFailed

func (s *Store) MarkFailed(ctx context.Context, id string, err error) error

MarkFailed increments retries and records the error. Sets status to failed when max retries reached, else back to pending.

func (*Store) MarkProcessed

func (s *Store) MarkProcessed(ctx context.Context, ids ...string) error

MarkProcessed marks messages as successfully processed.

func (*Store) Save

func (s *Store) Save(ctx context.Context, tx any, msgs ...outbox.Message) error

Save persists messages within the given transaction. tx may be a *sql.Tx, or nil to have the Store create its own transaction. Message IDs are generated by the Store when empty.

Jump to

Keyboard shortcuts

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