Documentation
¶
Overview ¶
Package patterns provides reusable workflow patterns for the workflow engine.
Index ¶
- type SagaBuilder
- func (b *SagaBuilder) AddActivityStep(name string, activity interface{}, input interface{}, ...) *SagaBuilder
- func (b *SagaBuilder) AddNonCriticalStep(name string, activity interface{}, input interface{}) *SagaBuilder
- func (b *SagaBuilder) AddStep(step SagaStep) *SagaBuilder
- func (b *SagaBuilder) Build() SagaInput
- func (b *SagaBuilder) WithMetadata(key, value string) *SagaBuilder
- func (b *SagaBuilder) WithTimeout(timeout time.Duration) *SagaBuilder
- type SagaInput
- type SagaOutput
- type SagaStep
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SagaBuilder ¶
type SagaBuilder struct {
// contains filtered or unexported fields
}
SagaBuilder provides a fluent interface for building saga workflows.
func NewSagaBuilder ¶
func NewSagaBuilder(workflowID string) *SagaBuilder
NewSagaBuilder creates a new saga builder.
func (*SagaBuilder) AddActivityStep ¶
func (b *SagaBuilder) AddActivityStep(name string, activity interface{}, input interface{}, compensateFn compensation.WorkflowCompensationFunc) *SagaBuilder
AddActivityStep adds an activity step with compensation.
func (*SagaBuilder) AddNonCriticalStep ¶
func (b *SagaBuilder) AddNonCriticalStep(name string, activity interface{}, input interface{}) *SagaBuilder
AddNonCriticalStep adds a step that won't trigger compensation on failure.
func (*SagaBuilder) AddStep ¶
func (b *SagaBuilder) AddStep(step SagaStep) *SagaBuilder
AddStep adds a step to the saga.
func (*SagaBuilder) Build ¶
func (b *SagaBuilder) Build() SagaInput
Build creates the SagaInput from the builder.
func (*SagaBuilder) WithMetadata ¶
func (b *SagaBuilder) WithMetadata(key, value string) *SagaBuilder
WithMetadata adds metadata to the saga.
func (*SagaBuilder) WithTimeout ¶
func (b *SagaBuilder) WithTimeout(timeout time.Duration) *SagaBuilder
WithTimeout sets the overall saga timeout.
type SagaInput ¶
type SagaInput struct {
WorkflowID string
Steps []SagaStep
Timeout time.Duration
Metadata map[string]string
}
SagaInput is the input for SagaWorkflow.
type SagaOutput ¶
type SagaOutput struct {
Status string `json:"status"`
CompletedSteps []string `json:"completedSteps"`
FailedStep string `json:"failedStep,omitempty"`
Error string `json:"error,omitempty"`
CompensationLogs []compensation.CompensationExecutionRecord `json:"compensationLogs,omitempty"`
Results map[string]interface{} `json:"results,omitempty"`
}
SagaOutput is the output from SagaWorkflow.
func SagaWithSignals ¶
func SagaWithSignals(ctx workflow.Context, input SagaInput) (SagaOutput, error)
SagaWithSignals executes a saga with support for manual compensation signals.
func SagaWorkflow ¶
func SagaWorkflow(ctx workflow.Context, input SagaInput) (SagaOutput, error)
SagaWorkflow executes activities with automatic compensation on failure.
type SagaStep ¶
type SagaStep struct {
Name string
Activity interface{}
Input interface{}
Output interface{}
CompensateFn compensation.WorkflowCompensationFunc
CompensateData interface{}
Timeout time.Duration
RetryPolicy *temporal.RetryPolicy
AllowFailure bool // If true, failure doesn't trigger compensation
}
SagaStep defines a single step in a saga workflow.