Versions in this module Expand all Collapse all v0 v0.1.1 Nov 10, 2026 v0.1.0 Nov 10, 2026 Changes in this version + const BucketMigrationOwner + const DebounceMigrationOwner + const DefaultOutputBytes + const DefaultOutputPerRun + const JournalMigrationOwner + const MigrationOwner + const OutputMigrationOwner + const UniqueMigrationOwner + var ErrAbandoned = errors.New("sqlstore: step abandoned by its workers") + var ErrLeaseLost = errors.New("sqlstore: step lease lost") + var ErrOutputNoRun = errors.New("sqlstore: output has no run (captured outside a driver)") + var ErrSchemaTooNew = errors.New("sqlstore: the database schema is newer than this code") + func DefaultIDGenerator(kind IDKind) (string, error) + type ArchiveFunc func(ctx context.Context, runs []FinishedRun) error + type ArchiveQuery struct + FinishedBefore time.Time + Limit int + RunID workflow.RunID + Workflow string + type BatchStore struct + func (b *BatchStore) Create(ctx context.Context, st batch.State) error + func (b *BatchStore) Get(ctx context.Context, id batch.ID) (batch.State, error) + func (b *BatchStore) Prune(ctx context.Context, f batch.PruneFilter) (int, error) + func (b *BatchStore) Unfinished(ctx context.Context) ([]batch.State, error) + func (b *BatchStore) Update(ctx context.Context, id batch.ID, fn func(*batch.State) error) (batch.State, error) + type BucketStore struct + func NewBucketStore(db *sql.DB, d sqlb.Dialect, opts ...Option) (*BucketStore, error) + func (s *BucketStore) Migrate(ctx context.Context) error + func (s *BucketStore) Observe(ctx context.Context, key string, spec workflow.BucketSpec, level float64, ...) error + func (s *BucketStore) Take(ctx context.Context, key string, spec workflow.BucketSpec, cost float64, ...) (time.Duration, error) + type Client struct + func New(db *sql.DB, d sqlb.Dialect, opts ...Option) (*Client, error) + func (c *Client) ArchivedRuns(ctx context.Context, q ArchiveQuery) ([]FinishedRun, error) + func (c *Client) BatchStore() *BatchStore + func (c *Client) BucketStore() *BucketStore + func (c *Client) Cancel(ctx context.Context, ref workflow.RunRef) error + func (c *Client) CancelAll(ctx context.Context, q workflow.RunQuery) (int, error) + func (c *Client) CancelStep(ctx context.Context, ref workflow.RunRef, step string) error + func (c *Client) Capabilities() workflow.Caps + func (c *Client) DB() *sql.DB + func (c *Client) DatabaseClock() *DatabaseClock + func (c *Client) DebounceStore() *DebounceStore + func (c *Client) Delete(ctx context.Context, ref workflow.RunRef) error + func (c *Client) Done() <-chan struct{} + func (c *Client) Drain(ctx context.Context) error + func (c *Client) DrainWithReport(ctx context.Context) (workflow.DrainReport, error) + func (c *Client) Enqueue(ctx context.Context, job workflow.Job) (workflow.RunRef, error) + func (c *Client) EnqueueMany(ctx context.Context, jobs []workflow.Job) ([]workflow.RunRef, error) + func (c *Client) EnqueueTx(ctx context.Context, tx *sql.Tx, job workflow.Job) (workflow.RunRef, error) + func (c *Client) ForceComplete(ctx context.Context, ref workflow.RunRef) error + func (c *Client) ForceFail(ctx context.Context, ref workflow.RunRef, reason string) error + func (c *Client) Health(ctx context.Context) workflow.HealthReport + func (c *Client) IndexLabels(ctx context.Context) (int, error) + func (c *Client) IsLeader() bool + func (c *Client) JournalStore() *JournalStore + func (c *Client) Migrate(ctx context.Context) error + func (c *Client) Nodes(ctx context.Context) ([]workflow.NodeInfo, error) + func (c *Client) OnLifecycle(fn workflow.LifecycleFunc) error + func (c *Client) OnRunFinished(fn workflow.RunFinishedFunc) error + func (c *Client) OnTick(fn workflow.TickObserver) error + func (c *Client) OutputStore(lim OutputLimits) *OutputStore + func (c *Client) Pause(ctx context.Context, t workflow.PauseTarget) error + func (c *Client) PauseSchedule(ctx context.Context, t workflow.ScheduleTarget) error + func (c *Client) Paused(ctx context.Context) ([]workflow.PauseTarget, error) + func (c *Client) PayloadLimit() int + func (c *Client) Prune(ctx context.Context) (PruneResult, error) + func (c *Client) QueueLoads(ctx context.Context) ([]workflow.QueueLoad, error) + func (c *Client) Register(wf workflow.Workflow) error + func (c *Client) Reschedule(ctx context.Context, ref workflow.RunRef, at time.Time) (workflow.RunRef, error) + func (c *Client) Result(ctx context.Context, ref workflow.RunRef) ([]byte, error) + func (c *Client) Resume(ctx context.Context, t workflow.PauseTarget) error + func (c *Client) ResumeSchedule(ctx context.Context, t workflow.ScheduleTarget) error + func (c *Client) Retry(ctx context.Context, ref workflow.RunRef) (workflow.RunRef, error) + func (c *Client) Runs(ctx context.Context, q workflow.RunQuery) (workflow.RunPage, error) + func (c *Client) Schedule(ctx context.Context, s workflow.Schedule) (workflow.ScheduleID, error) + func (c *Client) Schedules(ctx context.Context) ([]workflow.ScheduleInfo, error) + func (c *Client) SetWorkers(ctx context.Context, queue string, n int) error + func (c *Client) Signal(ctx context.Context, ev workflow.Event) error + func (c *Client) Start(ctx context.Context) error + func (c *Client) Status(ctx context.Context, ref workflow.RunRef) (workflow.Status, error) + func (c *Client) Stop() + func (c *Client) StopCause() error + func (c *Client) TriggerSchedule(ctx context.Context, id workflow.ScheduleID) (workflow.RunRef, error) + func (c *Client) UniqueStore() *UniqueStore + func (c *Client) Unschedule(ctx context.Context, id workflow.ScheduleID) error + func (c *Client) Wake() + type DatabaseClock struct + func NewDatabaseClock(db *sql.DB, d sqlb.Dialect) (*DatabaseClock, error) + func (k *DatabaseClock) NewTimer(d time.Duration) clock.Timer + func (k *DatabaseClock) Now() time.Time + func (k *DatabaseClock) Offset() time.Duration + func (k *DatabaseClock) Sync(ctx context.Context) error + func (k *DatabaseClock) Uncertainty() time.Duration + type DebounceStore struct + func NewDebounceStore(db *sql.DB, d sqlb.Dialect, opts ...Option) (*DebounceStore, error) + func (s *DebounceStore) Get(ctx context.Context, key string) (middleware.DebounceBurst, bool, error) + func (s *DebounceStore) Migrate(ctx context.Context) error + func (s *DebounceStore) PruneExpired(ctx context.Context) (int64, error) + func (s *DebounceStore) Swap(ctx context.Context, key string, b middleware.DebounceBurst) (middleware.DebounceBurst, bool, error) + type Elector interface + IsLeader func() bool + type ErrorClass struct + Retryable bool + Unavailable bool + UniqueViolation bool + func DefaultErrorClassifier(err error) ErrorClass + type ErrorClassifier func(err error) ErrorClass + type FinishedRun struct + CreatedAt time.Time + Err string + FinishedAt time.Time + Labels map[string]string + Outputs map[string][]byte + Payload []byte + Ref workflow.RunRef + Status workflow.Status + Workflow string + type IDGenerator func(kind IDKind) (string, error) + type IDKind string + const IDRun + const IDSchedule + const IDScheduled + const IDStep + type JournalStore struct + func NewJournalStore(db *sql.DB, d sqlb.Dialect, opts ...Option) (*JournalStore, error) + func (s *JournalStore) Forget(ctx context.Context, run workflow.RunID) error + func (s *JournalStore) Load(ctx context.Context, run workflow.RunID, key string) ([]byte, bool, error) + func (s *JournalStore) Migrate(ctx context.Context) error + func (s *JournalStore) Save(ctx context.Context, run workflow.RunID, key string, val []byte) error + type LeaderElector struct + func NewLeaderElector(db *sql.DB, d sqlb.Dialect, role, node string, opts ...LeaderOption) (*LeaderElector, error) + func (e *LeaderElector) Campaign(ctx context.Context) (bool, error) + func (e *LeaderElector) IsLeader() bool + func (e *LeaderElector) Resign(ctx context.Context) error + func (e *LeaderElector) Run(ctx context.Context) + func (e *LeaderElector) Term() int64 + type LeaderOption func(*LeaderElector) + func LeaderClock(c clock.Clock) LeaderOption + func LeaderLease(d time.Duration) LeaderOption + func LeaderSchema(name string) LeaderOption + func LeaderSkew(d time.Duration) LeaderOption + func LeaderTablePrefix(p string) LeaderOption + type MigrationScript struct + Name string + Owner string + Statements []string + func MigrationScripts(d sqlb.Dialect, opts ...Option) ([]MigrationScript, error) + type Notifier interface + Listen func(ctx context.Context, channel string, wake func()) error + Notify func(ctx context.Context, channel string) error + type Option func(*Client) + func WithArchive(fn ArchiveFunc) Option + func WithArchiveTable() Option + func WithClock(c clock.Clock) Option + func WithCronParser(p cron.Parser) Option + func WithDatabaseClock(resync time.Duration) Option + func WithElector(e Elector) Option + func WithEnqueueOnly() Option + func WithErrorClassifier(f ErrorClassifier) Option + func WithErrorHistory(n int) Option + func WithFetchBatch(n int) Option + func WithHousekeepingEvery(passes int) Option + func WithIDGenerator(g IDGenerator) Option + func WithJitterSource(rnd func() float64) Option + func WithLeaderElection(node string, opts ...LeaderOption) Option + func WithLease(d time.Duration) Option + func WithLeaseClock(c clock.Clock) Option + func WithLeaseSkew(d time.Duration) Option + func WithLogger(l *slog.Logger) Option + func WithMaxReclaims(n int) Option + func WithMiddleware(mw ...workflow.Middleware) Option + func WithNodeID(id string) Option + func WithNotifier(n Notifier) Option + func WithPayloadLimit(n int) Option + func WithPollInterval(d time.Duration) Option + func WithPruneChunk(n int) Option + func WithPruneInterval(d time.Duration) Option + func WithQueues(qs ...workflow.QueueConfig) Option + func WithRecycle(r workflow.Recycle) Option + func WithRetention(r Retention) Option + func WithSchedulerOnly() Option + func WithSchema(name string) Option + func WithStopWhenIdle(grace time.Duration) Option + func WithTablePrefix(p string) Option + func WithTickRetention(d time.Duration) Option + func WithTxAttempts(n int) Option + func WithWorkers(n int) Option + func WithoutAutoPrune() Option + func WithoutScheduler() Option + type OutputLimits struct + Bytes int + PerRun int + type OutputStore struct + func NewOutputStore(db *sql.DB, d sqlb.Dialect, lim OutputLimits, opts ...Option) (*OutputStore, error) + func (s *OutputStore) Deliver(ctx context.Context, out middleware.Output) error + func (s *OutputStore) Migrate(ctx context.Context) error + func (s *OutputStore) PruneBefore(ctx context.Context, t time.Time) (int64, error) + func (s *OutputStore) RunOutput(ctx context.Context, run workflow.RunID) ([]StoredOutput, error) + type PruneResult struct + Deleted int + HeldBatch int + HeldIdempotency int + HeldUndelivered int + type Retention struct + Cancelled time.Duration + Failed time.Duration + KeepLast int + PerWorkflow map[string]Retention + Succeeded time.Duration + Undelivered bool + type SchemaTooNewError struct + Unknown []string + func (e *SchemaTooNewError) Error() string + func (e *SchemaTooNewError) Is(target error) bool + type StoredOutput struct + Attempt int + Error string + Finished time.Time + Started time.Time + Step string + Text string + Truncated bool + type UniqueStore struct + func NewUniqueStore(db *sql.DB, d sqlb.Dialect, opts ...Option) (*UniqueStore, error) + func (u *UniqueStore) Acquire(ctx context.Context, key, owner string, ttl time.Duration) (bool, error) + func (u *UniqueStore) Holder(ctx context.Context, key string) (string, workflow.RunRef, bool, error) + func (u *UniqueStore) Migrate(ctx context.Context) error + func (u *UniqueStore) PruneExpired(ctx context.Context) (int64, error) + func (u *UniqueStore) Release(ctx context.Context, key, owner string) error + func (u *UniqueStore) SetHolder(ctx context.Context, key, owner string, ref workflow.RunRef) error