Versions in this module Expand all Collapse all v0 v0.1.0 Oct 18, 2026 Changes in this version + const MaxJobPageSize + var ErrDependencyFailed = errors.New("durable jobs: dependency failed") + var ErrInvalidJob = errors.New("durable jobs: invalid job") + var ErrInvalidTransition = errors.New("durable jobs: invalid transition") + var ErrJobExists = errors.New("durable jobs: job exists") + var ErrJobNotFound = errors.New("durable jobs: job not found") + var ErrNoReadyJob = errors.New("durable jobs: no ready job") + var ErrStaleAttempt = errors.New("durable jobs: stale attempt") + var ErrWakeupPublish = errors.New("durable jobs: wakeup publish") + func NewRecoveryEngine(store Store, clock Clock, policy reconciliation.Policy) (...) + func RetryDelay(policy RetryPolicy, attempt uint) time.Duration + func ValidateDependencies(ctx context.Context, store Store, dependencies []JobID) error + func ValidateEnqueue(request EnqueueRequest) error + func ValidateListJobPageRequest(request ListJobPageRequest) error + type Attempt struct + FencingToken coordination.FencingToken + HeartbeatDeadline time.Time + ID AttemptID + Job Job + StartedAt time.Time + WorkerID string + type AttemptID string + type Catalog interface + ListJobPage func(context.Context, ListJobPageRequest) (JobPage, error) + type ClaimRequest struct + FencingToken coordination.FencingToken + HeartbeatDeadline time.Time + Now time.Time + Queue Queue + WorkerID string + type Client interface + Cancel func(context.Context, JobID) error + Enqueue func(context.Context, EnqueueRequest) (Job, error) + Get func(context.Context, JobID) (Job, error) + type Clock interface + Now func() time.Time + type CompleteRequest struct + AttemptID AttemptID + CompletedAt time.Time + FencingToken coordination.FencingToken + Result Result + type DurableClient struct + func NewClient(store Store, publisher messaging.Publisher[Wakeup], clock Clock) (*DurableClient, error) + func (client *DurableClient) Cancel(ctx context.Context, id JobID) error + func (client *DurableClient) Enqueue(ctx context.Context, request EnqueueRequest) (Job, error) + func (client *DurableClient) Get(ctx context.Context, id JobID) (Job, error) + type EnqueueRequest struct + AvailableAt time.Time + DependsOn []JobID + Headers map[string]string + ID JobID + Kind string + Payload []byte + Priority int + Queue Queue + Retry RetryPolicy + func (request EnqueueRequest) Clone() EnqueueRequest + type Event struct + At time.Time + AttemptID AttemptID + Failure *Failure + JobID JobID + Kind EventKind + Queue Queue + type EventKind string + const EventCanceled + const EventEnqueued + const EventFailed + const EventHeartbeat + const EventRecovered + const EventRetryScheduled + const EventStarted + const EventSucceeded + type FailRequest struct + AttemptID AttemptID + FailedAt time.Time + Failure Failure + FencingToken coordination.FencingToken + NextAvailableAt time.Time + type Failure struct + Code string + Message string + Retryable bool + type Handler func(context.Context, Job) (Result, error) + type HeartbeatRequest struct + AttemptID AttemptID + Deadline time.Time + FencingToken coordination.FencingToken + type Job struct + Attempt uint + AvailableAt time.Time + CancellationRequested bool + CreatedAt time.Time + DependsOn []JobID + Headers map[string]string + ID JobID + Kind string + LastFailure *Failure + Payload []byte + Priority int + Queue Queue + Result []byte + Retry RetryPolicy + State State + UpdatedAt time.Time + func (job Job) Clone() Job + type JobID string + type JobPage struct + Jobs []Job + NextAfter JobID + type ListJobPageRequest struct + After JobID + Limit int + Queue Queue + type ListJobsRequest struct + Limit int + Queue Queue + type MapRegistry map[string]Handler + func (registry MapRegistry) Handler(kind string) (Handler, bool) + type Queue string + type RecoverAttemptRequest struct + AttemptID AttemptID + FencingToken coordination.FencingToken + HeartbeatDeadline time.Time + RecoveredAt time.Time + type RecoveryAction struct + AttemptID AttemptID + FencingToken coordination.FencingToken + HeartbeatDeadline time.Time + RecoveredAt time.Time + type RecoveryAdapter struct + Clock Clock + Store Store + func (RecoveryAdapter) Plan(ctx context.Context, desired reconciliation.Desired[RecoverySpec], ...) (reconciliation.Plan[RecoveryAction], error) + func (RecoveryAdapter) Undo(context.Context, reconciliation.Undo[RecoveryAction]) error + func (adapter RecoveryAdapter) Apply(ctx context.Context, action reconciliation.Action[RecoveryAction]) (reconciliation.Undo[RecoveryAction], error) + func (adapter RecoveryAdapter) Observe(ctx context.Context, _ reconciliation.Key) (RecoveryObserved, error) + type RecoveryCandidate struct + Attempt Attempt + ObservedAt time.Time + type RecoveryObserved struct + Candidates []RecoveryCandidate + ObservedAt time.Time + type RecoverySpec struct + Limit int + type Registry interface + Handler func(kind string) (Handler, bool) + type Result struct + Payload []byte + func (result Result) Clone() Result + type RetryPolicy struct + InitialBackoff time.Duration + MaxAttempts uint + MaxBackoff time.Duration + Multiplier float64 + type Schedule struct + Enabled bool + ID ScheduleID + Interval time.Duration + NextRunAt time.Time + Request EnqueueRequest + Revision uint64 + func (schedule Schedule) Clone() Schedule + type ScheduleID string + type ScheduleStore interface + AdvanceSchedule func(context.Context, ScheduleID, uint64, time.Time) error + GetSchedule func(context.Context, ScheduleID) (Schedule, error) + ListDueSchedules func(context.Context, time.Time, int) ([]Schedule, error) + PutSchedule func(context.Context, Schedule, uint64) (Schedule, error) + type Scheduler struct + func NewScheduler(store ScheduleStore, client Client, clock Clock) *Scheduler + func (scheduler *Scheduler) RunDue(ctx context.Context, limit int) (int, error) + type State uint8 + const StateCanceled + const StateFailed + const StatePending + const StateRetryWaiting + const StateRunning + const StateSucceeded + type Store interface + ClaimReady func(context.Context, ClaimRequest) (Attempt, error) + Complete func(context.Context, CompleteRequest) (Job, error) + Create func(context.Context, Job) (Job, error) + Fail func(context.Context, FailRequest) (Job, error) + Get func(context.Context, JobID) (Job, error) + Heartbeat func(context.Context, HeartbeatRequest) error + ListJobs func(context.Context, ListJobsRequest) ([]Job, error) + ListRecoveryCandidates func(context.Context, time.Time, int) ([]RecoveryCandidate, error) + RecoverAttempt func(context.Context, RecoverAttemptRequest) (Job, error) + RequestCancel func(context.Context, JobID, time.Time) (Job, error) + type Wakeup struct + AvailableAt time.Time + JobID JobID + Queue Queue + type Worker struct + func NewWorker(store Store, backend coordination.Backend, events messaging.Publisher[Event], ...) (*Worker, error) + func (worker *Worker) Run(ctx context.Context) error + func (worker *Worker) RunOne(ctx context.Context) (bool, error) + type WorkerOptions struct + ClaimLimit int + Clock Clock + HeartbeatInterval time.Duration + LeaseTTL time.Duration + PollInterval time.Duration + Queues []Queue + WorkerID string