command

package
v0.0.0-...-015de62 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2017 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodePreprocessorErr            = "PreprocessorErr"
	CodeEventLoadErr               = "EventLoadErr"
	CodeAggregateNotCommandHandler = "AggregateNotCommandHandler"
	CodeHandlerErr                 = "HandlerErr"
	CodeSaveErr                    = "SaveErr"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Constructor

type Constructor interface {
	New() bool
}

Constructor is an interface that a Command may implement to indicate the Command is the "constructor"

type Dispatcher

type Dispatcher interface {
	// Dispatch retrieves the Aggregate from the Repository, applies the Handler, and saves the result to the Repository
	Dispatch(ctx context.Context, cmd Interface) error
}

Dispatcher manages the execution of a command

func New

func New(repo eventsource.Repository, preprocessors ...Preprocessor) Dispatcher

New instantiates a new Dispatcher using the Repository and optional Preprocessors provided

type Handler

type Handler interface {
	Apply(ctx context.Context, command Interface) ([]eventsource.Event, error)
}

type Interface

type Interface interface {
	AggregateID() string
}

type Model

type Model struct {
	ID string
}

func (Model) AggregateID

func (m Model) AggregateID() string

type Preprocessor

type Preprocessor interface {
	// Before is executed prior to the Handler.Apply call
	Before(ctx context.Context, cmd Interface) error
}

Preprocessor manipulates commands prior to them being executed by the Handler

Jump to

Keyboard shortcuts

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