projector

package
v0.0.0-...-6efc50b Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrModelNotSet = errors.New("model not set")

ErrModelNotSet is when a model factory is not set on the EventHandler.

Functions

This section is empty.

Types

type Error

type Error struct {
	// Err is the error.
	Err error
	// BaseErr is an optional underlying error, for example from the DB driver.
	BaseErr error
	// Namespace is the namespace for the error.
	Namespace string
}

Error is an error in the projector, with the namespace.

func (Error) Error

func (e Error) Error() string

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

type EventHandler

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

EventHandler is a CQRS projection handler to run a Projector implementation.

func NewEventHandler

func NewEventHandler(projector Projector, repo eh.ReadWriteRepo) *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 EventHandler interface. It will try to find the correct version of the model, waiting for it if needed.

func (*EventHandler) HandlerType

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

HandlerType implements the HandlerType method of the EventHandler interface.

func (*EventHandler) SetEntityFactory

func (h *EventHandler) SetEntityFactory(f func() eh.Entity)

SetEntityFactory sets a factory function that creates concrete entity types.

type Projector

type Projector interface {
	// Project projects an event onto a model and returns the updated model or
	// an error.
	Project(context.Context, eh.Event, eh.Entity) (eh.Entity, error)

	// ProjectorType returns the type of the projector.
	ProjectorType() Type
}

Projector is a projector of events onto models.

type Type

type Type string

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

Jump to

Keyboard shortcuts

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