Documentation
¶
Overview ¶
Package postgres is a persistent, multi-process rerun.Store backed by PostgreSQL via the pure-Go, cgo-free driver github.com/lib/pq. Its lease is a session-scoped advisory lock, so a lease held by a worker that dies is released automatically when that worker's connection drops — no expiry, no heartbeat, no reaper.
Index ¶
- type Store
- func (s *Store) Acquire(ctx context.Context, runID string) (io.Closer, bool, error)
- func (s *Store) Append(ctx context.Context, runID string, l rerun.Log) error
- func (s *Store) CancelRequested(ctx context.Context, runID string) (bool, error)
- func (s *Store) Close() error
- func (s *Store) Create(ctx context.Context, r rerun.Run) error
- func (s *Store) Finish(ctx context.Context, runID string, st rerun.Status) error
- func (s *Store) Incomplete(ctx context.Context) ([]rerun.Run, error)
- func (s *Store) LoadLogs(ctx context.Context, runID string) ([]rerun.Log, error)
- func (s *Store) PopSignal(ctx context.Context, runID, name string) ([]byte, bool, error)
- func (s *Store) PushSignal(ctx context.Context, runID, name string, payload []byte) error
- func (s *Store) RequestCancel(ctx context.Context, runID string) 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 is a Postgres-backed rerun.Store.
func New ¶
New opens the database at dsn and migrates it to the latest schema. Unlike the SQLite store it does not cap the pool: Postgres handles concurrency, and the lease's exclusivity depends on a competing Acquire landing on a second connection so it observes the lock as held. A v0.1 database is adopted and upgraded in place.
func (*Store) Acquire ¶
Acquire takes a session-scoped advisory lock on a dedicated connection. pg_try_advisory_lock is non-blocking, so a competing worker (a different session) observes acquired=false. If this worker's process dies the connection drops and Postgres releases the lock automatically, which is what makes a crashed run recoverable across machines.
func (*Store) Append ¶
Append inserts a journal row, returning rerun.ErrSeqConflict on a duplicate (run, seq) position.
func (*Store) CancelRequested ¶
CancelRequested reports whether a cancel has been recorded for the run.
func (*Store) Create ¶
Create inserts a new run row, returning rerun.ErrRunExists on a duplicate ID.
func (*Store) Incomplete ¶
Incomplete returns every run still Pending or Running.
func (*Store) PushSignal ¶
PushSignal and PopSignal implement rerun.Signaler: a durable, per-run, per-name FIFO mailbox. A signal delivered before the workflow reaches Wait waits in the table until Wait pops it, and survives a crash in between.