saga

package
v0.0.0-...-36d8597 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuilderStep

type BuilderStep struct {
	*Step
	// contains filtered or unexported fields
}

func (*BuilderStep) Build

func (s *BuilderStep) Build() (*Step, []error)

func (*BuilderStep) Needs

func (s *BuilderStep) Needs(keys []string) *BuilderStep

func (*BuilderStep) Reject

func (s *BuilderStep) Reject(f func(ctx context.Context) error) *BuilderStep

func (*BuilderStep) Then

func (s *BuilderStep) Then(f func(ctx context.Context) error) *BuilderStep

type Option

type Option func(*Options)

func Logger

func Logger(logger logger.Logger) Option

type Options

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

type Saga

type Saga struct {

	// options
	Options
	// contains filtered or unexported fields
}

func (*Saga) AddStep

func (s *Saga) AddStep(name string, setters ...Option) *BuilderStep

func (*Saga) Play

func (s *Saga) Play(initSteps map[string]*Step) error

func (*Saga) Reject

func (s *Saga) Reject(rejectSteps map[string]*Step) error

type SagaBuilder

type SagaBuilder struct {
	*Saga
	// contains filtered or unexported fields
}

func New

func New(name string, setters ...Option) *SagaBuilder

func (*SagaBuilder) Build

func (s *SagaBuilder) Build() (*Saga, []error)

func (*SagaBuilder) WithContext

func (s *SagaBuilder) WithContext(ctx context.Context) *SagaBuilder

type Step

type Step struct {

	// options
	Options
	// contains filtered or unexported fields
}

func (*Step) Reject

func (s *Step) Reject() error

func (*Step) Run

func (s *Step) Run() error

type StepState

type StepState int
const (
	INIT StepState = iota
	WAIT
	RUN
	DONE
	REJECT
	FAIL
	ROLLBACK
)

Success chain: INIT -> WAIT -> RUN -> DONE Fail chain: INIT -> WAIT -> RUN -> REJECT -> FAIL or ROLLBACK

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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