Documentation
¶
Overview ¶
Package sqlite implements engine.CheckpointStore on top of SQLite.
The driver is modernc.org/sqlite (pure Go, no cgo) so this backend works on every Go platform without a C toolchain. The store is suitable for single-process daemons (vesseld), embedded examples, and tests; for multi-writer workloads use the postgres backend.
Usage ¶
store, err := sqlite.Open(ctx, "file:checkpoints.db?_pragma=journal_mode(WAL)")
if err != nil { return err }
defer store.Close()
// Wire into engine.LoadAndResume / engine.Host.Checkpointer.
Schema ¶
The store keeps the latest checkpoint per ExecID. Older checkpoints for the same exec id are overwritten in place (UPSERT). Callers that need a full history should write their own append-only table — checkpoints are the engine's "where to resume from" record, not an audit log.
Schema is created idempotently by Open; it is also exposed as [Migrate] for callers that want to run the migration explicitly (e.g. before a rolling deploy).
Index ¶
- type Option
- type Store
- func (s *Store) Close() error
- func (s *Store) Delete(ctx context.Context, execID string) error
- func (s *Store) List(ctx context.Context) ([]string, error)
- func (s *Store) Load(ctx context.Context, execID string) (*engine.Checkpoint, error)
- func (s *Store) Migrate(ctx context.Context) error
- func (s *Store) Save(ctx context.Context, cp engine.Checkpoint) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store persists engine.Checkpoint records in a SQLite database. One row per ExecID; Save UPSERTs the latest snapshot. Safe for concurrent use across goroutines (database/sql handles pooling).
func Open ¶
Open creates a Store backed by a fresh database/sql connection pool against dsn. The Store takes ownership of the pool — closing the Store closes the pool. Migrations are run synchronously before Open returns.
dsn is passed verbatim to modernc.org/sqlite; common forms:
- "file:checkpoints.db?_pragma=journal_mode(WAL)" — on-disk WAL
- "file::memory:?cache=shared" — in-memory shared (for tests)
func Wrap ¶
Wrap builds a Store on top of an existing *sql.DB. The caller retains ownership of db; closing the Store does not close the underlying pool. Migrate must be called before any Save / Load when callers use Wrap.
func (*Store) Close ¶
Close releases resources owned by the Store. Safe to call repeatedly; only the first call has an effect when the Store owns its DB.
func (*Store) Delete ¶
Delete removes the checkpoint for execID. Missing exec ids are a no-op (no error). Implements engine.CheckpointDeleter.
func (*Store) List ¶
List enumerates persisted exec ids. Implements engine.CheckpointLister.