saga

package
v0.14.3 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2021 License: Apache-2.0 Imports: 3 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error added in v0.9.0

type Error struct {
	// Err is the error that happened when projecting the event.
	Err error
	// Saga is the saga where the error happened.
	Saga string
}

Error is an error in the projector.

func (Error) Cause added in v0.9.0

func (e Error) Cause() error

Cause implements the github.com/pkg/errors Unwrap method.

func (Error) Error added in v0.9.0

func (e Error) Error() string

Error implements the Error method of the errors.Error interface.

func (Error) Unwrap added in v0.9.0

func (e Error) Unwrap() error

Unwrap implements the errors.Unwrap method.

type EventHandler

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

EventHandler is a CQRS saga handler to run a Saga implementation.

func NewEventHandler

func NewEventHandler(saga Saga, commandHandler eh.CommandHandler) *EventHandler

NewEventHandler creates a new EventHandler.

func (*EventHandler) HandleEvent

func (h *EventHandler) HandleEvent(ctx context.Context, event eh.Event) error

HandleEvent implements the HandleEvent method of the eventhorizon.EventHandler interface.

func (*EventHandler) HandlerType added in v0.4.0

func (h *EventHandler) HandlerType() eh.EventHandlerType

HandlerType implements the HandlerType method of the eventhorizon.EventHandler interface.

type Saga

type Saga interface {
	// SagaType returns the type of the saga.
	SagaType() Type

	// RunSaga handles an event in the saga that can return commands.
	// If an error is returned from the saga, the event will be run again.
	RunSaga(context.Context, eh.Event, eh.CommandHandler) error
}

Saga is an interface for a CQRS saga that listens to events and generate commands. It is used for any long lived transaction and can be used to react on multiple events.

type Type

type Type string

Type is the type of a saga, used as its unique identifier.

func (Type) String added in v0.8.0

func (t Type) String() string

String returns the string representation of a saga type.

Jump to

Keyboard shortcuts

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