aggregate

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyEvent

func ApplyEvent(aggregate cqrs.Aggregate, track bool, event cqrs.Event) error

ApplyEvent ...

func ApplyEvents

func ApplyEvents(aggregate cqrs.Aggregate, track bool, events ...cqrs.Event) error

ApplyEvents ...

func ApplyHistory

func ApplyHistory(aggregate cqrs.Aggregate, events ...cqrs.Event) error

ApplyHistory ...

func Config

func Config() cqrs.AggregateConfig

Config ...

func Repository

func Repository(eventStore cqrs.EventStore, aggregateCfg cqrs.AggregateConfig) cqrs.AggregateRepository

Repository ...

func Snapshotter

Snapshotter ...

func Use

func Use(
	ctx context.Context,
	repo cqrs.AggregateRepository,
	typ cqrs.AggregateType,
	id uuid.UUID,
	version int,
	use func(context.Context, cqrs.Aggregate) error,
) (cqrs.Aggregate, error)

Use ...

func UseLatest

func UseLatest(
	ctx context.Context,
	repo cqrs.AggregateRepository,
	typ cqrs.AggregateType,
	id uuid.UUID,
	use func(context.Context, cqrs.Aggregate) error,
) (cqrs.Aggregate, error)

UseLatest ...

Types

type BaseAggregate

type BaseAggregate struct {
	ID      uuid.UUID
	Type    cqrs.AggregateType
	Version int
	// contains filtered or unexported fields
}

BaseAggregate is the base implementation for an aggregate.

func Base

func Base(typ cqrs.AggregateType, id uuid.UUID) *BaseAggregate

Base returns a new BaseAggregate.

func (*BaseAggregate) AggregateID

func (a *BaseAggregate) AggregateID() uuid.UUID

AggregateID returns the aggregate ID.

func (*BaseAggregate) AggregateType

func (a *BaseAggregate) AggregateType() cqrs.AggregateType

AggregateType returns the type name of the aggregate.

func (*BaseAggregate) Changes

func (a *BaseAggregate) Changes() []cqrs.Event

Changes returns the applied events.

func (*BaseAggregate) CurrentVersion

func (a *BaseAggregate) CurrentVersion() int

CurrentVersion returns the version of the aggregate after applying the changes.

func (*BaseAggregate) FlushChanges

func (a *BaseAggregate) FlushChanges()

FlushChanges sets the original version to the current version and clears the changes.

func (*BaseAggregate) NewEvent

func (a *BaseAggregate) NewEvent(typ cqrs.EventType, data cqrs.EventData) cqrs.Event

NewEvent ...

func (*BaseAggregate) NewEventWithTime

func (a *BaseAggregate) NewEventWithTime(typ cqrs.EventType, data cqrs.EventData, time time.Time) cqrs.Event

NewEventWithTime ...

func (*BaseAggregate) OriginalVersion

func (a *BaseAggregate) OriginalVersion() int

OriginalVersion returns the original version of the aggregate.

func (*BaseAggregate) TrackChange

func (a *BaseAggregate) TrackChange(events ...cqrs.Event)

TrackChange adds applied events to the aggregate.

type IllegalVersionError

type IllegalVersionError struct {
	Err error
}

IllegalVersionError ...

func (IllegalVersionError) Error

func (err IllegalVersionError) Error() string

func (IllegalVersionError) Unwrap

func (err IllegalVersionError) Unwrap() error

type SnapshotConfig

type SnapshotConfig interface {
	IsDue(cqrs.Aggregate) bool
}

SnapshotConfig ...

func ConfigureSnapshots

func ConfigureSnapshots(options ...SnapshotOption) SnapshotConfig

ConfigureSnapshots ...

type SnapshotError

type SnapshotError struct {
	Err       error
	StoreName string
}

SnapshotError ...

func (SnapshotError) Error

func (err SnapshotError) Error() string

func (SnapshotError) Unwrap

func (err SnapshotError) Unwrap() error

Unwrap ...

type SnapshotOption

type SnapshotOption func(*snapshotConfig)

SnapshotOption ...

func SnapshotInterval

func SnapshotInterval(typ cqrs.AggregateType, every int) SnapshotOption

SnapshotInterval ...

type UnregisteredError

type UnregisteredError struct {
	AggregateType cqrs.AggregateType
}

UnregisteredError is raised when an event type is not registered.

func (UnregisteredError) Error

func (err UnregisteredError) Error() string

Jump to

Keyboard shortcuts

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