Documentation
¶
Overview ¶
Package sqlstore persists immutable workflow definitions in a tenant DB.
Index ¶
- func DefinitionSchemaStatements(dialect db.Dialect) ([]string, error)
- func ExecutionSchemaStatements(dialect db.Dialect) ([]string, error)
- func RegisterSignalConsumer(dispatcher *outbox.Dispatcher, store *ExecutionStore, tenant contract.TenantID, ...) error
- type AuthorizationStore
- func (s *AuthorizationStore) Subject(ctx context.Context, subject contract.SubjectRef) (workflow.SubjectAuthorization, error)
- func (s *AuthorizationStore) UserRoles(ctx context.Context, site string, principal contract.PrincipalID) ([]string, bool, error)
- func (s *AuthorizationStore) WorkflowStarter(ctx context.Context, tenant contract.TenantID, instance contract.InstanceID) (contract.PrincipalID, error)
- type DefinitionStore
- func (s *DefinitionStore) Ensure(ctx context.Context) error
- func (s *DefinitionStore) GetDefinition(ctx context.Context, tenant contract.TenantID, id contract.DefinitionID, ...) (contract.WorkflowDefinition, contract.DefinitionVersionRef, error)
- func (s *DefinitionStore) GetStatusPolicy(ctx context.Context, tenant contract.TenantID, table string) (*workflow.StatusPolicy, bool, error)
- func (s *DefinitionStore) GetStatusPolicyInTx(ctx context.Context, tx *sql.Tx, tenant contract.TenantID, table string) (*workflow.StatusPolicy, bool, error)
- func (s *DefinitionStore) HasSuccessfulPreview(ctx context.Context, tenant contract.TenantID, id contract.DefinitionID, ...) (bool, error)
- func (s *DefinitionStore) ListLatestDefinitions(ctx context.Context, tenant contract.TenantID) ([]contract.DefinitionVersionRef, error)
- func (s *DefinitionStore) ListPreviews(ctx context.Context, tenant contract.TenantID, limit uint16) ([]workflow.PreviewRun, error)
- func (s *DefinitionStore) PublishDefinition(ctx context.Context, tenant contract.TenantID, ...) (contract.DefinitionVersionRef, error)
- func (s *DefinitionStore) PublishImportedBatch(ctx context.Context, tenant contract.TenantID, actor contract.PrincipalID, ...) error
- func (s *DefinitionStore) RecordPreview(ctx context.Context, tenant contract.TenantID, actor contract.PrincipalID, ...) error
- type ExecutionStore
- func (s *ExecutionStore) AcceptSignal(ctx context.Context, signal workflow.Signal) (uint32, error)
- func (s *ExecutionStore) AcceptSignalInTx(ctx context.Context, tx *sql.Tx, signal workflow.Signal) (uint32, error)
- func (s *ExecutionStore) BeginExternalAttempt(ctx context.Context, claim workflow.Claim, executionID string, ...) (*contract.PinnedDispatch, error)
- func (s *ExecutionStore) BeginPinnedExternalAttempt(ctx context.Context, claim workflow.Claim, executionID string, ...) (*workflow.PinnedCapabilityAttempt, error)
- func (s *ExecutionStore) ClaimDue(ctx context.Context, tenant contract.TenantID, owner string, limit uint16, ...) ([]workflow.Claim, error)
- func (s *ExecutionStore) CommitHumanWaitInTx(ctx context.Context, tx *sql.Tx, prepared *requests.PreparedSubmission, ...) (requests.RequestRecord, error)
- func (s *ExecutionStore) CommitStep(ctx context.Context, change workflow.StepCommit) error
- func (s *ExecutionStore) CommitStepInTx(ctx context.Context, tx *sql.Tx, change workflow.StepCommit) error
- func (s *ExecutionStore) CreateHumanWait(ctx context.Context, prepared *requests.PreparedSubmission, ...) (requests.RequestRecord, error)
- func (s *ExecutionStore) Release(ctx context.Context, claim workflow.Claim) error
- func (s *ExecutionStore) Renew(ctx context.Context, claim workflow.Claim, lease time.Duration) (workflow.Claim, error)
- func (s *ExecutionStore) ResumeDueTimedWaits(ctx context.Context, tenant contract.TenantID, limit uint16) (uint16, error)
- func (s *ExecutionStore) ResumeEventSignals(ctx context.Context, tenant contract.TenantID, limit uint16) (uint16, error)
- func (s *ExecutionStore) ResumeTerminalHumanWaits(ctx context.Context, tenant contract.TenantID, limit uint16) (uint16, error)
- func (s *ExecutionStore) ValidateClaimInTx(ctx context.Context, tx *sql.Tx, claim workflow.Claim) error
- type InstanceStore
- func (s *InstanceStore) Cancel(ctx context.Context, change workflow.CancelCommit) (contract.WorkflowInstance, error)
- func (s *InstanceStore) GetInstance(ctx context.Context, tenant contract.TenantID, id contract.InstanceID) (contract.WorkflowInstance, error)
- func (s *InstanceStore) InspectOpenWork(ctx context.Context, tenant contract.TenantID, module contract.ModuleID, ...) ([]contract.ModuleBlocker, error)
- func (s *InstanceStore) ListHistory(ctx context.Context, tenant contract.TenantID, id contract.InstanceID, ...) ([]workflow.HistoryEntry, error)
- func (s *InstanceStore) ListRecentInstances(ctx context.Context, tenant contract.TenantID, limit uint16) ([]contract.WorkflowInstance, error)
- func (s *InstanceStore) LoadPinnedCapabilityAttempt(ctx context.Context, tenant contract.TenantID, instance contract.InstanceID, ...) (workflow.PinnedCapabilityAttempt, error)
- func (s *InstanceStore) Reconcile(ctx context.Context, change workflow.ReconcileCommit) (contract.WorkflowInstance, error)
- func (s *InstanceStore) StartInstance(ctx context.Context, input workflow.StartInstanceInput) (contract.WorkflowInstance, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecutionSchemaStatements ¶
ExecutionSchemaStatements returns the tables used by unified durable workflow execution.
func RegisterSignalConsumer ¶
func RegisterSignalConsumer(dispatcher *outbox.Dispatcher, store *ExecutionStore, tenant contract.TenantID, eventTypes []string) error
RegisterSignalConsumer joins workflow inbox acceptance to the outbox consumer receipt for the tenant database owned by this store. The allowlist must contain only event types whose payload correlation fields have been registered by the workflow/domain catalog.
Types ¶
type AuthorizationStore ¶
type AuthorizationStore struct {
// contains filtered or unexported fields
}
AuthorizationStore reads live membership, subject ownership and persisted workflow starter data for the application policy layer.
func NewAuthorizationStore ¶
func (*AuthorizationStore) Subject ¶
func (s *AuthorizationStore) Subject(ctx context.Context, subject contract.SubjectRef) (workflow.SubjectAuthorization, error)
func (*AuthorizationStore) UserRoles ¶
func (s *AuthorizationStore) UserRoles(ctx context.Context, site string, principal contract.PrincipalID) ([]string, bool, error)
func (*AuthorizationStore) WorkflowStarter ¶
func (s *AuthorizationStore) WorkflowStarter(ctx context.Context, tenant contract.TenantID, instance contract.InstanceID) (contract.PrincipalID, error)
type DefinitionStore ¶
type DefinitionStore struct {
// contains filtered or unexported fields
}
func NewDefinitionStore ¶
func (*DefinitionStore) GetDefinition ¶
func (s *DefinitionStore) GetDefinition(ctx context.Context, tenant contract.TenantID, id contract.DefinitionID, version uint32) (contract.WorkflowDefinition, contract.DefinitionVersionRef, error)
func (*DefinitionStore) GetStatusPolicy ¶
func (s *DefinitionStore) GetStatusPolicy(ctx context.Context, tenant contract.TenantID, table string) (*workflow.StatusPolicy, bool, error)
func (*DefinitionStore) GetStatusPolicyInTx ¶
func (s *DefinitionStore) GetStatusPolicyInTx(ctx context.Context, tx *sql.Tx, tenant contract.TenantID, table string) (*workflow.StatusPolicy, bool, error)
GetStatusPolicyInTx assembles policy from latest published status-action steps in the caller's record transaction.
func (*DefinitionStore) HasSuccessfulPreview ¶
func (s *DefinitionStore) HasSuccessfulPreview(ctx context.Context, tenant contract.TenantID, id contract.DefinitionID, version uint32, digest string) (bool, error)
HasSuccessfulPreview checks the exact immutable definition content that is about to be published. Sample record values are never stored or consulted.
func (*DefinitionStore) ListLatestDefinitions ¶
func (s *DefinitionStore) ListLatestDefinitions(ctx context.Context, tenant contract.TenantID) ([]contract.DefinitionVersionRef, error)
ListLatestDefinitions returns the newest published version of each workflow for one tenant. The tenant predicate is applied before grouping so no cross-tenant metadata can be exposed.
func (*DefinitionStore) ListPreviews ¶
func (s *DefinitionStore) ListPreviews(ctx context.Context, tenant contract.TenantID, limit uint16) ([]workflow.PreviewRun, error)
func (*DefinitionStore) PublishDefinition ¶
func (s *DefinitionStore) PublishDefinition(ctx context.Context, tenant contract.TenantID, definition contract.WorkflowDefinition, actor contract.PrincipalID, key contract.IdempotencyKey, now time.Time) (contract.DefinitionVersionRef, error)
PublishDefinition stores one immutable version and a scoped idempotency receipt atomically. It must only be called after definition validation.
func (*DefinitionStore) PublishImportedBatch ¶
func (s *DefinitionStore) PublishImportedBatch(ctx context.Context, tenant contract.TenantID, actor contract.PrincipalID, definitions []contract.WorkflowDefinition, now time.Time) error
PublishImportedBatch atomically publishes a validated set of v2 definitions from a tenant configuration import. Matching immutable rows make retries safe; conflicts roll back the whole batch.
func (*DefinitionStore) RecordPreview ¶
func (s *DefinitionStore) RecordPreview(ctx context.Context, tenant contract.TenantID, actor contract.PrincipalID, run workflow.PreviewRun) error
type ExecutionStore ¶
type ExecutionStore struct {
// contains filtered or unexported fields
}
func NewExecutionStore ¶
func (*ExecutionStore) AcceptSignal ¶
AcceptSignal persists the event inbox item and advances a bounded set of matching waits in one transaction. A trusted event consumer should use AcceptSignalInTx so its own consumer receipt commits with this inbox write.
func (*ExecutionStore) AcceptSignalInTx ¶
func (s *ExecutionStore) AcceptSignalInTx(ctx context.Context, tx *sql.Tx, signal workflow.Signal) (uint32, error)
AcceptSignalInTx accepts an event into the durable inbox using a caller-owned transaction. Event identity is tenant-scoped and repeated delivery is safe.
func (*ExecutionStore) BeginExternalAttempt ¶
func (s *ExecutionStore) BeginExternalAttempt(ctx context.Context, claim workflow.Claim, executionID string, key contract.IdempotencyKey, requested *contract.PinnedDispatch) (*contract.PinnedDispatch, error)
BeginExternalAttempt records ownership and retry identity before a provider call. If the process dies after the effect starts, recovery can distinguish that uncertain outcome from an attempt that was never sent.
func (*ExecutionStore) BeginPinnedExternalAttempt ¶
func (s *ExecutionStore) BeginPinnedExternalAttempt(ctx context.Context, claim workflow.Claim, executionID string, key contract.IdempotencyKey, requested contract.PinnedDispatch, lease contract.CapabilityLease) (*workflow.PinnedCapabilityAttempt, error)
func (*ExecutionStore) CommitHumanWaitInTx ¶
func (s *ExecutionStore) CommitHumanWaitInTx(ctx context.Context, tx *sql.Tx, prepared *requests.PreparedSubmission, change workflow.StepCommit) (requests.RequestRecord, error)
CommitHumanWaitInTx creates the request and pauses the claimed workflow in the caller-owned transaction. Any error requires the caller to roll back; neither request nor workflow store owns the transaction lifecycle.
func (*ExecutionStore) CommitStep ¶
func (s *ExecutionStore) CommitStep(ctx context.Context, change workflow.StepCommit) error
CommitStep persists attempt, instance progress, timer state, history and required events under the same fenced transaction. It does not execute a business mutation; local actions must use LocalActionExecutor.
func (*ExecutionStore) CommitStepInTx ¶
func (s *ExecutionStore) CommitStepInTx(ctx context.Context, tx *sql.Tx, change workflow.StepCommit) error
CommitStepInTx appends a fenced workflow transition to a caller-owned local transaction. It leaves commit and rollback ownership to the caller, allowing coordinated request/domain writes to commit with workflow progress.
func (*ExecutionStore) CreateHumanWait ¶
func (s *ExecutionStore) CreateHumanWait(ctx context.Context, prepared *requests.PreparedSubmission, change workflow.StepCommit) (requests.RequestRecord, error)
CreateHumanWait owns a local tenant transaction for the request and wait registration. Both records and their outbox events commit or roll back together.
func (*ExecutionStore) ResumeDueTimedWaits ¶
func (s *ExecutionStore) ResumeDueTimedWaits(ctx context.Context, tenant contract.TenantID, limit uint16) (uint16, error)
ResumeDueTimedWaits advances due generic wait steps to their timeout edge. It verifies the immutable definition and commits the fenced state transition, timer deletion, history, and event in one tenant transaction. Human steps are left to request terminal-state recovery.
func (*ExecutionStore) ResumeEventSignals ¶
func (s *ExecutionStore) ResumeEventSignals(ctx context.Context, tenant contract.TenantID, limit uint16) (uint16, error)
ResumeEventSignals recovers accepted signals left pending by a bounded consumer pass or process interruption. Each event/instance pair is fenced by a unique receipt and commits with the instance transition and outbox event.
func (*ExecutionStore) ResumeTerminalHumanWaits ¶
func (s *ExecutionStore) ResumeTerminalHumanWaits(ctx context.Context, tenant contract.TenantID, limit uint16) (uint16, error)
ResumeTerminalHumanWaits advances a bounded batch of paused instances whose source request is terminal. It polls durable request state, so it also recovers when outbox delivery or a worker was unavailable. The request, pinned definition, waiting step, history, and event are resolved in one transaction; conditional updates make retries harmless.
func (*ExecutionStore) ValidateClaimInTx ¶
func (s *ExecutionStore) ValidateClaimInTx(ctx context.Context, tx *sql.Tx, claim workflow.Claim) error
ValidateClaimInTx locks the running instance row before a transaction-bound local domain operation. The caller must keep the returned transaction open through the domain mutation and CommitStepInTx, so another worker cannot replace the fence between validation and commit.
type InstanceStore ¶
type InstanceStore struct {
// contains filtered or unexported fields
}
func NewInstanceStore ¶
func (*InstanceStore) Cancel ¶
func (s *InstanceStore) Cancel(ctx context.Context, change workflow.CancelCommit) (contract.WorkflowInstance, error)
func (*InstanceStore) GetInstance ¶
func (s *InstanceStore) GetInstance(ctx context.Context, tenant contract.TenantID, id contract.InstanceID) (contract.WorkflowInstance, error)
func (*InstanceStore) InspectOpenWork ¶
func (s *InstanceStore) InspectOpenWork(ctx context.Context, tenant contract.TenantID, module contract.ModuleID, limit uint16) ([]contract.ModuleBlocker, error)
InspectOpenWork reports bounded nonterminal workflow instances whose pinned definition is owned by the module. The query uses existing definition and instance stores and returns opaque IDs only.
func (*InstanceStore) ListHistory ¶
func (s *InstanceStore) ListHistory(ctx context.Context, tenant contract.TenantID, id contract.InstanceID, limit uint16) ([]workflow.HistoryEntry, error)
func (*InstanceStore) ListRecentInstances ¶
func (s *InstanceStore) ListRecentInstances(ctx context.Context, tenant contract.TenantID, limit uint16) ([]contract.WorkflowInstance, error)
func (*InstanceStore) LoadPinnedCapabilityAttempt ¶
func (s *InstanceStore) LoadPinnedCapabilityAttempt(ctx context.Context, tenant contract.TenantID, instance contract.InstanceID, step contract.StepID) (workflow.PinnedCapabilityAttempt, error)
func (*InstanceStore) Reconcile ¶
func (s *InstanceStore) Reconcile(ctx context.Context, change workflow.ReconcileCommit) (contract.WorkflowInstance, error)
Reconcile applies an authorized operator decision to an uncertain action. The command receipt, state/fence transition, immutable history and event are written in one transaction. Replays return the original result snapshot.
func (*InstanceStore) StartInstance ¶
func (s *InstanceStore) StartInstance(ctx context.Context, input workflow.StartInstanceInput) (contract.WorkflowInstance, error)