sqlite

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 26 Imported by: 0

README

SQLite backend

SQLite embeds workflow persistence in one application host. File-backed workers can reopen persisted history after restart. In-memory databases do not survive process exit. This backend does not establish distributed SQLite operation across machines.

Connections and migrations

NewSqliteBackend(path) owns its connection, enables WAL, configures a busy timeout, limits the pool to one open connection and applies embedded migrations by default. NewInMemoryBackend creates a unique named in-memory database and retains a connection to keep it alive.

NewSqliteBackendWithDB uses a caller-owned *sql.DB, does not close it and disables migrations by default. The caller must configure WAL, busy timeout and pool size. Enable migrations explicitly with WithApplyMigrations(true) when appropriate. Constructors can panic when initialization or automatic migration fails.

Maintaining the backend

Embedded migrations live in db/migrations, with paired .up.sql and .down.sql files. Follow the existing sequence and preserve published migrations. Back up a consistent database before applying schema changes; copying a live main file alone can omit data still in its WAL.

Run make test-sqlite for backend contracts and make test-recovery for file-backed worker recovery. See backend operations and testing.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewInMemoryBackend

func NewInMemoryBackend(opts ...option) *sqliteBackend

func NewSqliteBackend

func NewSqliteBackend(path string, opts ...option) *sqliteBackend

func NewSqliteBackendWithDB

func NewSqliteBackendWithDB(db *sql.DB, opts ...option) *sqliteBackend

NewSqliteBackendWithDB creates a new SQLite backend using an existing database connection. When using this constructor, the backend will not close the database connection when Close() is called. Migrations can still be applied using WithApplyMigrations(true) as SQLite does not require special connection settings for migrations. Note: The caller is responsible for configuring the connection appropriately (e.g., WAL mode, busy timeout, max open connections).

func WithApplyMigrations

func WithApplyMigrations(applyMigrations bool) option

WithApplyMigrations automatically applies database migrations on startup.

func WithBackendOptions

func WithBackendOptions(opts ...backend.BackendOption) option

WithBackendOptions allows to pass generic backend options.

Types

type Scanner

type Scanner interface {
	Scan(dest ...interface{}) error
}

Jump to

Keyboard shortcuts

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