Documentation
¶
Index ¶
- Constants
- func AcquireLock(ctx context.Context, key string, ttl time.Duration, timeout time.Duration) (bool, error)
- func Emit(ctx context.Context, eventType string, payload any) error
- func GetEventBus(ctx context.Context) mdk.EventBus
- func GetWorkflowID(ctx context.Context) string
- func RegisterStore(name string, provider StoreProvider)
- func ReleaseLock(ctx context.Context, key string) error
- func WithRunner(ctx context.Context, r *Runner, id string) context.Context
- type InMemStore
- func (s *InMemStore) Close() error
- func (s *InMemStore) GetInput(ctx context.Context, execID string) ([]byte, error)
- func (s *InMemStore) GetState(ctx context.Context, execID string) (map[string]string, error)
- func (s *InMemStore) GetStepOutput(ctx context.Context, execID string, stepID string) ([]byte, error)
- func (s *InMemStore) InitializeExecution(ctx context.Context, execID string, input []byte) error
- func (s *InMemStore) IsEventEmitted(ctx context.Context, execID string, eventType string) (bool, error)
- func (s *InMemStore) ListExecutions(ctx context.Context, state string) ([]string, error)
- func (s *InMemStore) RecordEventEmitted(ctx context.Context, execID string, eventType string) error
- func (s *InMemStore) SaveInput(ctx context.Context, execID string, input []byte) error
- func (s *InMemStore) SaveState(ctx context.Context, execID string, stepID string, state string) error
- func (s *InMemStore) SaveStepOutput(ctx context.Context, execID string, stepID string, output []byte) error
- func (s *InMemStore) SetTTL(ctx context.Context, execID string, ttl time.Duration) error
- type Parser
- type Registry
- type Runner
- func (r *Runner) Cancel(ctx context.Context, runID string) error
- func (r *Runner) Execute(ctx context.Context, workflowID string, input map[string]any) (string, error)
- func (r *Runner) ExecuteSync(ctx context.Context, id string, workflowID string, input map[string]any) (map[string]any, error)
- func (r *Runner) ExecuteSyncWorkflow(ctx context.Context, id string, wf *Workflow, input any) (map[string]any, error)
- func (r *Runner) GetStateStore() StateStore
- func (r *Runner) Register(w mdk.Workflow) error
- func (r *Runner) RegisterHandler(name string, handler mdk.StepHandler) error
- func (r *Runner) ResumeExecution(ctx context.Context, id string, wf *Workflow) (map[string]any, error)
- func (r *Runner) SetRuntime(rt mdk.Runtime)
- func (r *Runner) Status(ctx context.Context, runID string) (mdk.StepStatus, error)
- type StateStore
- type Step
- type StepContext
- type StepHandler
- type StepResult
- type StepStatus
- type StoreProvider
- type Workflow
Constants ¶
const ( StatePending = "PENDING" StateRunning = "RUNNING" StateCompleted = "COMPLETED" StateFailed = "FAILED" StateWaitingHuman = "WAITING_HUMAN" StateRetrying = "RETRYING" StateFallback = "FALLBACK" StateCompensating = "COMPENSATING" )
Workflow and Step statuses.
const ( ActionRetry = "retry" ActionCancel = "cancel" )
Action types for human intervention.
const ( BackoffExponential = "exponential" BackoffConstant = "constant" )
Backoff strategies.
const ( EventWorkflowStarted = "workflow.started" EventWorkflowCompleted = "workflow.completed" EventWorkflowFailed = "workflow.failed" EventWorkflowCompensating = "workflow.compensating" EventStepStarted = "workflow.step.started" EventStepCompleted = "workflow.step.completed" EventStepFailed = "workflow.step.failed" EventStepRetrying = "workflow.step.retrying" EventStepFallback = "workflow.step.fallback" EventWaitingHuman = "workflow.waiting_human" )
Workflow Event types.
const ( StepPending = mdk.StepPending StepRunning = mdk.StepRunning StepCompleted = mdk.StepCompleted StepFailed = mdk.StepFailed StepRetrying = mdk.StepRetrying StepSkipped = mdk.StepSkipped )
const (
EscalationWaitHuman = "wait_human"
)
Escalation strategies.
Variables ¶
This section is empty.
Functions ¶
func AcquireLock ¶
func AcquireLock(ctx context.Context, key string, ttl time.Duration, timeout time.Duration) (bool, error)
AcquireLock attempts to acquire a lock for the current workflow.
func Emit ¶
Emit sends an event to the EventBus attached to the current workflow runner. It is idempotent: it tracks emitted events in the StateStore to prevent duplicates during resumption.
func GetEventBus ¶
GetEventBus retrieves the EventBus attached to the current workflow runner.
func GetWorkflowID ¶
GetWorkflowID retrieves the current executing Workflow ID from the context.
func RegisterStore ¶ added in v0.2.0
func RegisterStore(name string, provider StoreProvider)
func ReleaseLock ¶
ReleaseLock releases a lock for the current workflow.
Types ¶
type InMemStore ¶
type InMemStore struct {
// contains filtered or unexported fields
}
InMemStore is an in-memory implementation of StateStore for local testing.
func (*InMemStore) Close ¶
func (s *InMemStore) Close() error
func (*InMemStore) GetStepOutput ¶
func (*InMemStore) InitializeExecution ¶
func (*InMemStore) IsEventEmitted ¶
func (*InMemStore) ListExecutions ¶
func (*InMemStore) RecordEventEmitted ¶
func (*InMemStore) SaveStepOutput ¶
type Parser ¶
type Parser struct{}
Parser parses and validates workflow definitions.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages the registration of workflow definitions.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner executes workflow instances.
func (*Runner) Execute ¶
func (r *Runner) Execute(ctx context.Context, workflowID string, input map[string]any) (string, error)
Execute starts an asynchronous workflow run and returns the run ID.
func (*Runner) ExecuteSync ¶
func (r *Runner) ExecuteSync(ctx context.Context, id string, workflowID string, input map[string]any) (map[string]any, error)
ExecuteSync runs a workflow synchronously and returns the output results map.
func (*Runner) ExecuteSyncWorkflow ¶
func (r *Runner) ExecuteSyncWorkflow(ctx context.Context, id string, wf *Workflow, input any) (map[string]any, error)
ExecuteSyncWorkflow runs a workflow synchronously and returns the results map.
func (*Runner) GetStateStore ¶
func (r *Runner) GetStateStore() StateStore
GetStateStore returns the StateStore attached to the runner.
func (*Runner) RegisterHandler ¶
func (r *Runner) RegisterHandler(name string, handler mdk.StepHandler) error
RegisterHandler registers a named step handler.
func (*Runner) ResumeExecution ¶
func (r *Runner) ResumeExecution(ctx context.Context, id string, wf *Workflow) (map[string]any, error)
ResumeExecution resumes a previously crashed or interrupted workflow.
func (*Runner) SetRuntime ¶
SetRuntime sets the active mdk.Runtime for execution context.
type StateStore ¶
type StateStore = mdk.StateStore
StateStore defines the interface for checkpointing workflow states.
func GetStateStore ¶
func GetStateStore(ctx context.Context) StateStore
GetStateStore retrieves the StateStore attached to the current workflow runner.
type StepContext ¶
type StepContext = mdk.StepContext
type StepHandler ¶
type StepHandler = mdk.StepHandler
type StepResult ¶
type StepResult = mdk.StepResult
type StepStatus ¶
type StepStatus = mdk.StepStatus
type StoreProvider ¶ added in v0.2.0
type StoreProvider = mdk.StoreProvider
func GetStore ¶ added in v0.2.0
func GetStore(name string) (StoreProvider, bool)