Documentation
¶
Index ¶
- func EnsureAuditTables(ctx context.Context, db *sql.DB) error
- func RecordTransition(ctx context.Context, db *sql.DB, ev TransitionAudit) error
- type InstanceState
- type LeaseStore
- func (s *LeaseStore) Acquire(ctx context.Context, site, workflow, instanceID, owner string, ...) (InstanceState, error)
- func (s *LeaseStore) EnsureTables(ctx context.Context) error
- func (s *LeaseStore) Load(ctx context.Context, site, workflow, instanceID string) (InstanceState, error)
- func (s *LeaseStore) Release(ctx context.Context, site, workflow, instanceID, owner string) error
- func (s *LeaseStore) Renew(ctx context.Context, site, workflow, instanceID, owner string, ...) (InstanceState, error)
- func (s *LeaseStore) Upsert(ctx context.Context, st InstanceState) error
- type QueueMetrics
- type Runtime
- func (r *Runtime) DeadLetter(ctx context.Context, state InstanceState, cause string) error
- func (r *Runtime) Ensure(ctx context.Context) error
- func (r *Runtime) Pause(ctx context.Context, state InstanceState, owner string) error
- func (r *Runtime) ProcessDue(ctx context.Context, now time.Time, limit int, owner string) ([]InstanceState, error)
- func (r *Runtime) Resume(ctx context.Context, site, workflowName, instanceID, owner string) (InstanceState, error)
- func (r *Runtime) Retry(ctx context.Context, state InstanceState, after time.Duration) error
- type StepHandler
- type TimerScheduler
- func (s *TimerScheduler) Delete(ctx context.Context, site, workflow, instanceID string) error
- func (s *TimerScheduler) DeleteAt(ctx context.Context, site, workflow, instanceID string, wakeAt time.Time) error
- func (s *TimerScheduler) DeleteID(ctx context.Context, site, workflow, instanceID, timerID string) error
- func (s *TimerScheduler) Due(ctx context.Context, now time.Time, limit int) ([]InstanceState, error)
- func (s *TimerScheduler) EnsureTables(ctx context.Context) error
- func (s *TimerScheduler) Schedule(ctx context.Context, site, workflow, instanceID, timerID string, ...) error
- type TransitionAudit
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RecordTransition ¶
Types ¶
type InstanceState ¶
type InstanceState struct {
Site string `json:"site"`
Workflow string `json:"workflow"`
InstanceID string `json:"instance_id"`
Version int64 `json:"version"`
LeaseOwner string `json:"lease_owner"`
LeaseUntil time.Time `json:"lease_until"`
TimerID string `json:"timer_id,omitempty"`
NextWakeAt time.Time `json:"next_wake_at,omitempty"`
WakeAt time.Time `json:"wake_at,omitempty"`
Status string `json:"status"`
Payload json.RawMessage `json:"payload,omitempty"`
UpdatedAt time.Time `json:"updated_at"`
}
InstanceState is the persisted workflow actor state used for lease/fencing and timer recovery.
type LeaseStore ¶
LeaseStore persists and fences actor ownership.
func (*LeaseStore) Acquire ¶
func (s *LeaseStore) Acquire(ctx context.Context, site, workflow, instanceID, owner string, ttl time.Duration) (InstanceState, error)
func (*LeaseStore) EnsureTables ¶
func (s *LeaseStore) EnsureTables(ctx context.Context) error
func (*LeaseStore) Load ¶
func (s *LeaseStore) Load(ctx context.Context, site, workflow, instanceID string) (InstanceState, error)
func (*LeaseStore) Release ¶
func (s *LeaseStore) Release(ctx context.Context, site, workflow, instanceID, owner string) error
func (*LeaseStore) Renew ¶
func (s *LeaseStore) Renew(ctx context.Context, site, workflow, instanceID, owner string, ttl time.Duration) (InstanceState, error)
func (*LeaseStore) Upsert ¶
func (s *LeaseStore) Upsert(ctx context.Context, st InstanceState) error
type QueueMetrics ¶
func CollectMetrics ¶
type Runtime ¶
type Runtime struct {
LeaseStore *LeaseStore
TimerScheduler *TimerScheduler
StepHandler StepHandler
LeaseTTL time.Duration
}
Runtime wires lease/fencing, timers, and step execution together.
func NewRuntime ¶
func NewRuntime(db *sql.DB, handler StepHandler) *Runtime
func (*Runtime) DeadLetter ¶
DeadLetter persists a terminal failure state for operator recovery.
func (*Runtime) ProcessDue ¶
func (r *Runtime) ProcessDue(ctx context.Context, now time.Time, limit int, owner string) ([]InstanceState, error)
ProcessDue resumes any due workflow instances using the supplied owner identity. It is a small recovery loop for timer-driven workflows and returns the states that were successfully resumed.
type StepHandler ¶
type StepHandler func(ctx context.Context, state InstanceState, doc *doctype.Document) (InstanceState, error)
StepHandler executes one workflow step against a document snapshot.
type TimerScheduler ¶
TimerScheduler tracks due workflow wakeups with SQL persistence.
func (*TimerScheduler) Delete ¶
func (s *TimerScheduler) Delete(ctx context.Context, site, workflow, instanceID string) error
func (*TimerScheduler) DeleteID ¶
func (s *TimerScheduler) DeleteID(ctx context.Context, site, workflow, instanceID, timerID string) error
func (*TimerScheduler) Due ¶
func (s *TimerScheduler) Due(ctx context.Context, now time.Time, limit int) ([]InstanceState, error)
func (*TimerScheduler) EnsureTables ¶
func (s *TimerScheduler) EnsureTables(ctx context.Context) error