saga

package module
v0.0.0-...-2bda2b1 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompensationError

type CompensationError struct {
	Errors []error
}

CompensationError implements the error interface and aggregates the compensation errors that occur during execution

func (*CompensationError) Error

func (e *CompensationError) Error() string

type ParallelCompensator

type ParallelCompensator struct {
	// contains filtered or unexported fields
}

ParallelCompensator implements the Saga interface it executes compensations in parallel

func NewParallelCompensator

func NewParallelCompensator(ctx workflow.Context) *ParallelCompensator

NewParallelCompensator returns a new instance of a ParallelCompensator

func (*ParallelCompensator) AddCompensation

func (p *ParallelCompensator) AddCompensation(activity interface{}, args ...interface{})

AddCompensation adds a rollback compensation step

func (*ParallelCompensator) Cancel

func (p *ParallelCompensator) Cancel()

Cancel cancels the Saga context

func (*ParallelCompensator) Compensate

func (p *ParallelCompensator) Compensate() error

Compensate executes all the compensation operations that have been defined in parallel After the first call, subsequent calls to a Compensate do nothing.

type Saga

type Saga interface {
	// AddCompensation adds a rollback compensation to the Saga
	AddCompensation(activity interface{}, args ...interface{})
	// Compensate executes all the compensation operations that have been defined
	Compensate() error
	// Cancel cancels the Saga context
	Cancel()
}

Saga defines the interface for Saga compensations

type SerialCompensator

type SerialCompensator struct {
	// contains filtered or unexported fields
}

SerialCompensator implements the Saga interface it executes compensations serially, in FI-LO (stack) order

func NewSerialCompensator

func NewSerialCompensator(ctx workflow.Context, continueOnError bool) *SerialCompensator

NewSerialCompensator returns a new instance of a SerialCompensator

if continueOnError is true, it will ignore errors that occur when running Compensate

func (*SerialCompensator) AddCompensation

func (s *SerialCompensator) AddCompensation(activity interface{}, args ...interface{})

AddCompensation adds a rollback compensation step

func (*SerialCompensator) Cancel

func (s *SerialCompensator) Cancel()

Cancel cancels the saga execution

func (*SerialCompensator) Compensate

func (s *SerialCompensator) Compensate() error

Compensate serially executes all the compensation operations that have been defined After the first call, subsequent calls to a Compensate do nothing.

Jump to

Keyboard shortcuts

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