sqlstore

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2026 License: AGPL-3.0, AGPL-3.0-or-later Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sqlstore persists immutable workflow definitions in a tenant DB.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefinitionSchemaStatements

func DefinitionSchemaStatements(dialect db.Dialect) ([]string, error)

func ExecutionSchemaStatements

func ExecutionSchemaStatements(dialect db.Dialect) ([]string, error)

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 NewAuthorizationStore(database *sql.DB, dialect db.Dialect, registry *doctype.Registry) (*AuthorizationStore, error)

func (*AuthorizationStore) Subject

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 NewDefinitionStore(database *sql.DB, dialect db.Dialect) (*DefinitionStore, error)

func (*DefinitionStore) Ensure

func (s *DefinitionStore) Ensure(ctx context.Context) 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

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 NewExecutionStore(database *sql.DB, dialect db.Dialect) (*ExecutionStore, error)

func (*ExecutionStore) AcceptSignal

func (s *ExecutionStore) AcceptSignal(ctx context.Context, signal workflow.Signal) (uint32, error)

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) ClaimDue

func (s *ExecutionStore) ClaimDue(ctx context.Context, tenant contract.TenantID, owner string, limit uint16, lease time.Duration) ([]workflow.Claim, 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

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) Release

func (s *ExecutionStore) Release(ctx context.Context, claim workflow.Claim) error

func (*ExecutionStore) Renew

func (s *ExecutionStore) Renew(ctx context.Context, claim workflow.Claim, lease time.Duration) (workflow.Claim, error)

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 NewInstanceStore(database *sql.DB, dialect db.Dialect) (*InstanceStore, error)

func (*InstanceStore) Cancel

func (*InstanceStore) GetInstance

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

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL