Versions in this module Expand all Collapse all v0 v0.17.0 Oct 29, 2026 v0.16.0 Oct 17, 2026 v0.15.0 Oct 17, 2026 v0.14.0 Oct 17, 2026 v0.13.2 Oct 16, 2026 v0.13.1 Oct 12, 2026 v0.13.0 Oct 11, 2026 v0.12.0 Oct 9, 2026 v0.11.0 Oct 7, 2026 v0.10.0 Oct 5, 2026 Changes in this version + var ErrBusy = errors.New("saga: the engine is answering other questions; ask again") + var ErrNoSaga = errors.New("saga: the engine runs no such saga") type Config + InspectData bool v0.9.0 Oct 5, 2026 Changes in this version + const MaxInbox + const MetadataFence + const MetadataKey + var ErrEnded = errors.New("saga: the run has ended") + var ErrFired = errors.New("saga: the effect has fired already") + var ErrInboxFull = errors.New("saga: the run's inbox is full") + var ErrLost = errors.New("saga: the run has another owner") + var ErrNoRun = errors.New("saga: no such run") + func KeyOf(md grpcproc.Metadata) (key string, fence uint64, ok bool) + func Permanent(err error) error + type Config struct + Concurrency int + Lease time.Duration + Name string + Poll time.Duration + Store Store + type Definition struct + func Define[D proto.Message, S comparable](name string, m *fsm.Machine[S]) *Definition[S, D] + func Sequence[D proto.Message](name string, steps ...*StepSpec[D]) (*Definition[Stage, D], error) + func (d *Definition[S, D]) AcceptSignal(ev fsm.Event[fsm.Unit]) *Definition[S, D] + func (d *Definition[S, D]) Accept[P proto.Message](ev fsm.Event[P], apply func(data D, p P)) *Definition[S, D] + func (d *Definition[S, D]) After(state S, after time.Duration, ev fsm.Event[fsm.Unit]) *Definition[S, D] + func (d *Definition[S, D]) Begin(ctx context.Context, e *Engine, id string, data D) (bool, error) + func (d *Definition[S, D]) Do(state S, effect Effect[S, D], opts ...StepOption) *Definition[S, D] + func (d *Definition[S, D]) Get(ctx context.Context, e *Engine, id string) (Snapshot[S, D], error) + func (d *Definition[S, D]) Notify(ctx context.Context, e *Engine, id string, ev fsm.Event[fsm.Unit]) error + func (d *Definition[S, D]) Resume(ctx context.Context, e *Engine, id string) error + func (d *Definition[S, D]) Signal[P proto.Message](ctx context.Context, e *Engine, id string, ev fsm.Event[P], p P) error + func (d *Definition[S, D]) Version(v uint64) *Definition[S, D] + func (d *Definition[S, D]) Wait(ctx context.Context, e *Engine, id string) (Snapshot[S, D], error) + type Effect func(ctx context.Context, r *Run[S, D]) error + type Engine struct + func Start(n *grpcproc.Node, cfg Config, sagas ...Saga) (*Engine, error) + func (e *Engine) PID() grpcproc.PID + type Record struct + Attempts int + Cause string + Consumed []uint64 + CreatedAt time.Time + Data []byte + Deadline time.Time + EffectDone bool + Epoch uint64 + Error string + ID string + Inbox []Signal + LeaseUntil time.Time + Owner string + RetryAt time.Time + Revision uint64 + Saga string + SagaVersion uint64 + Seen uint64 + State string + Status Status + UpdatedAt time.Time + Visit uint64 + Wake time.Time + type Run struct + Data D + func (r *Run[S, D]) Attempt() int + func (r *Run[S, D]) Fence() uint64 + func (r *Run[S, D]) Fire[A any](ctx context.Context, ev fsm.Event[A], arg A) error + func (r *Run[S, D]) ID() string + func (r *Run[S, D]) Key() string + func (r *Run[S, D]) Process() *grpcproc.Process[proto.Message] + func (r *Run[S, D]) State() S + type Saga interface + type Signal struct + Event string + Payload []byte + Seq uint64 + Version uint64 + type Snapshot struct + Attempts int + Cause string + Data D + Error string + ID string + State S + Status Status + Updated time.Time + type Stage string + const StageDone + const StageFailed + type Status uint8 + const Active + const Done + const Stuck + func (s Status) String() string + type StepOption func(*step) + func Attempts(n int) StepOption + func Backoff(lo, hi time.Duration) StepOption + func Otherwise(ev fsm.Event[string]) StepOption + type StepSpec struct + func Step[D proto.Message](name string, do Effect[Stage, D], opts ...StepOption) *StepSpec[D] + func (s *StepSpec[D]) Pivot() *StepSpec[D] + func (s *StepSpec[D]) Undo(undo Effect[Stage, D], opts ...StepOption) *StepSpec[D] + type Store interface + Claim func(ctx context.Context, owner string, sagas map[string]uint64, ttl time.Duration, ...) ([]Record, error) + Create func(ctx context.Context, r Record) (Record, bool, error) + Get func(ctx context.Context, saga, id string) (Record, bool, error) + List func(ctx context.Context, saga string) ([]Record, error) + Renew func(ctx context.Context, saga, id string, epoch uint64, ttl time.Duration) error + Resume func(ctx context.Context, saga, id string) error + Save func(ctx context.Context, r Record) (Record, error) + Signal func(ctx context.Context, saga, id string, s Signal) error + func Memory() Store