Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMissingBus is returned when trying to publish an event without an // event.Bus or dispatch a Command without a command.Bus. ErrMissingBus = errors.New("missing bus") // ErrMissingRepository is returned when trying to fetch an aggregate with // an . ErrMissingRepository = errors.New("missing repository") )
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action interface { // Name returns the name of the Action. Name() string // Run runs the Action. Run(Context) error }
Action is a SAGA action.
type Context ¶
type Context interface { context.Context // Action returns the currently executed Action. Action() Action // Publish publishes the given events via the underlying Event Bus. If no // Event Bus is available, Publish returns ErrMissingBus. Publish(context.Context, ...event.Event) error // Dispatch synchronously dispatches the given Command via the underlying // Command Bus. If no Command Bus is available, Dispatch returns ErrMissingBus. Dispatch(context.Context, command.Command, ...command.DispatchOption) error // Fetch fetches the provided aggregate from the underlying Aggregate // Repository. If no aggregate Repository is available, Fetch returns // ErrMissingRepository. Fetch(context.Context, aggregate.Aggregate) error // Run runs the Action with the specified name. Run(context.Context, string) error }
Context is the context for running actions.
func NewContext ¶
func NewContext(parent context.Context, act Action, opts ...ContextOption) Context
NewContext returns a new Context for the given Action.
type ContextOption ¶
type ContextOption func(*actionContext)
A ContextOption configures a Context.
func WithCommandBus ¶
func WithCommandBus(bus command.Bus) ContextOption
WithCommandBus returns a ContextOption that provides the Context with a command.Bus.
func WithEventBus ¶
func WithEventBus(bus event.Bus) ContextOption
WithEventBus returns a ContextOption that provides the Context with an event.Bus.
func WithRepository ¶
func WithRepository(r aggregate.Repository) ContextOption
WithRepository returns a ContextOption that provides the Context with an .
func WithRunner ¶
func WithRunner(run func(context.Context, string) error) ContextOption
WithRunner returns a ContextOption that specifies the runner function that is called when ctx.Run is called.
type Option ¶
type Option func(*Report)
An Option adds information to a Report.
func CompensatedBy ¶
CompensatedBy returns a Option that adds the Report of a compensating Action to the Report of a failed Action.