Documentation
¶
Overview ¶
Package saga implements the Saga pattern for distributed transactions.
It allows defining a sequence of steps where each step has a corresponding compensation. If any step fails, the compensations of all executed steps are triggered in reverse order. It supports tree-structured sagas with conditional execution and retries for compensation.
Package saga provides a simple way to define a step in a sequence of steps.
Index ¶
- func New[T any](nodes ...Node[T]) tree[T]
- func WithChilds[T any](childs ...Node[T]) nodeOption[T]
- func WithCompensation[T any](compensation StepRunner[T]) nodeOption[T]
- func WithCondition[T any](condition func(T) bool) nodeOption[T]
- func WithStep[T any](step StepRunner[T]) nodeOption[T]
- type Node
- type ResultMerger
- type StepRunner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithChilds ¶
func WithCompensation ¶
func WithCompensation[T any](compensation StepRunner[T]) nodeOption[T]
func WithCondition ¶
func WithStep ¶
func WithStep[T any](step StepRunner[T]) nodeOption[T]
Types ¶
type StepRunner ¶
func ParallelSteps ¶
func ParallelSteps[T any](mergeStep ResultMerger[T], steps ...StepRunner[T]) StepRunner[T]
ParallelSteps executes the steps in parallel. Use it when you do not need the result of one to execute the next one.
func SerialSteps ¶
func SerialSteps[T any](steps ...StepRunner[T]) StepRunner[T]
SerialSteps executes the steps in serial. Use it when you want to execute steps in serial.
Click to show internal directories.
Click to hide internal directories.