model

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidAggregate = errors.New("invalid aggregate")

ErrInvalidAggregate occurs when a loaded aggregate is not an aggregate.

View Source
var ErrInvalidRepo = errors.New("invalid repo")

ErrInvalidRepo is when a dispatcher is created with a nil repo.

Functions

This section is empty.

Types

type AggregateStore

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

AggregateStore is an aggregate store that uses a read write repo for loading and saving aggregates.

func NewAggregateStore

func NewAggregateStore(repo eh.ReadWriteRepo, bus eh.EventBus) (*AggregateStore, error)

NewAggregateStore creates an aggregate store with a read write repo.

func (*AggregateStore) Load

func (r *AggregateStore) Load(ctx context.Context, aggregateType eh.AggregateType, id eh.UUID) (eh.Aggregate, error)

Load implements the Load method of the eventhorizon.AggregateStore interface.

func (*AggregateStore) Save

func (r *AggregateStore) Save(ctx context.Context, aggregate eh.Aggregate) error

Save implements the Save method of the eventhorizon.AggregateStore interface.

type EventPublisher

type EventPublisher interface {
	// EventsToPublish returns all events to publish.
	EventsToPublish() []eh.Event
}

EventPublisher is an optional event publisher that can be implemented by aggregates to allow for publishing of events on a successful save.

type SliceEventPublisher

type SliceEventPublisher []eh.Event

SliceEventPublisher is an EventPublisher using a slice to store events.

func (*SliceEventPublisher) EventsToPublish

func (a *SliceEventPublisher) EventsToPublish() []eh.Event

EventsToPublish implements the EventsToPublish method of the EventPublisher interface.

func (*SliceEventPublisher) PublishEvent

func (a *SliceEventPublisher) PublishEvent(e eh.Event)

PublishEvent registers an event to be published after the aggregate has been successfully saved.

Jump to

Keyboard shortcuts

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