Documentation
¶
Overview ¶
Package postgres implements engine.CheckpointStore on top of PostgreSQL.
The driver is github.com/jackc/pgx/v5 (used directly via pgxpool; no database/sql layer). Suitable for multi-process daemons, horizontally scaled vesseld fleets, and production durability requirements where SQLite's single-writer model is insufficient.
Usage ¶
store, err := postgres.Open(ctx, "postgres://flowcraft:secret@db:5432/flowcraft?sslmode=disable")
if err != nil { return err }
defer store.Close()
// Wire into engine.LoadAndResume / engine.Host.Checkpointer.
Schema ¶
One row per ExecID; Save uses INSERT ... ON CONFLICT DO UPDATE so the table always holds the latest checkpoint per execution. Migrations run idempotently inside Open; expose [Migrate] for callers that want explicit control.
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 PostgreSQL table. One row per ExecID; Save UPSERTs the latest snapshot. Safe for concurrent use across goroutines and processes (the unique constraint on exec_id makes the UPSERT idempotent).
func Open ¶
Open creates a Store backed by a fresh pgxpool.Pool against dsn. The Store takes ownership of the pool — closing the Store closes the pool. Migrations are run synchronously before Open returns.
func Wrap ¶
Wrap builds a Store on top of an existing pgxpool.Pool. The caller retains ownership of pool; closing the Store does not close it. 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 pool.
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.