sagaclient

package
v1.27.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConfigNotSet               = errors.New("config not set")
	ErrClientNotSet               = errors.New("client not set")
	ErrSagasNotSet                = errors.New("sagas not set")
	ErrLoggerNotSet               = errors.New("logger not set")
	ErrRetryPolicyNotSet          = errors.New("retry policy not set")
	ErrActionActivityNotSet       = errors.New("action activity not set")
	ErrCompensationActivityNotSet = errors.New("compensation activity not set")
	ErrActivityOptionsNotSet      = errors.New("activity options not set")
	ErrIdentifierNotSet           = errors.New("identifier not set")
	ErrSagaWorkflowNotFound       = errors.New("saga workflow not found")
	ErrStartWorkflowOptionsNotSet = errors.New("start workflow options not set")
	ErrInputNotSet                = errors.New("input not set")
)

Functions

This section is empty.

Types

type ExecuteSagaParams

type ExecuteSagaParams struct {
	Identifier string
	Options    *client.StartWorkflowOptions
	Input      []interface{}
}

type ExecuteSagaResult

type ExecuteSagaResult struct {
	WorkflowID string
	RunID      string
}

type SagaActivityFunc

type SagaActivityFunc = func(ctx context.Context, input any) (err error)

type SagaClient

type SagaClient struct {
	Client          client.Client
	RegisteredSagas map[string]WorkflowFunc
	Logger          *zap.Logger
}

func NewSagaClient

func NewSagaClient(options ...SagaClientOption) (*SagaClient, error)

func (*SagaClient) Execute

func (c *SagaClient) Execute(ctx context.Context, param *ExecuteSagaParams) (*ExecuteSagaResult, error)

type SagaClientOption

type SagaClientOption func(*SagaClient)

func WithClient

func WithClient(client client.Client) SagaClientOption

func WithLogger

func WithLogger(logger *zap.Logger) SagaClientOption

func WithSagaCustomWorkflows

func WithSagaCustomWorkflows(sagaWf ...SagaWorkflow) SagaClientOption

type SagaWorkflow

type SagaWorkflow struct {
	ActionActivity       SagaActivityFunc
	CompensationActivity SagaActivityFunc
	Options              *workflow.ActivityOptions
	Identifier           string
}

func NewSagaWorkflow

func NewSagaWorkflow(options ...SagaWorkflowOption) (*SagaWorkflow, error)

NewSagaWorkflow creates a new SagaWorkflow.

type SagaWorkflowOption

type SagaWorkflowOption func(*SagaWorkflow)

SagaWorkflowOption defines the signature for functions that can configure SagaWorkflow

func WithActionActivity

func WithActionActivity(activityFunc SagaActivityFunc) SagaWorkflowOption

WithActionActivity configures the action activity and its options.

func WithActivityOptions

func WithActivityOptions(options workflow.ActivityOptions) SagaWorkflowOption

WithActivityOptions configures the activity options.

func WithCompensationActivity

func WithCompensationActivity(activityFunc SagaActivityFunc) SagaWorkflowOption

WithCompensationActivity configures the compensation activity and its options.

func WithIdentifier

func WithIdentifier(identifier string) SagaWorkflowOption

WithIdentifier configures the identifier.

type WorkflowFunc

type WorkflowFunc = func(workflow.Context, ...interface{}) (err error)

Jump to

Keyboard shortcuts

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