Documentation ¶
Index ¶
- func ApplyEvent(aggregate cqrs.Aggregate, track bool, event cqrs.Event) error
- func ApplyEvents(aggregate cqrs.Aggregate, track bool, events ...cqrs.Event) error
- func ApplyHistory(aggregate cqrs.Aggregate, events ...cqrs.Event) error
- func Config() cqrs.AggregateConfig
- func Repository(eventStore cqrs.EventStore, aggregateCfg cqrs.AggregateConfig) cqrs.AggregateRepository
- func Snapshotter(aggregates cqrs.AggregateRepository, cfg SnapshotConfig, ...) cqrs.AggregateRepository
- func Use(ctx context.Context, repo cqrs.AggregateRepository, typ cqrs.AggregateType, ...) (cqrs.Aggregate, error)
- func UseLatest(ctx context.Context, repo cqrs.AggregateRepository, typ cqrs.AggregateType, ...) (cqrs.Aggregate, error)
- type BaseAggregate
- func (a *BaseAggregate) AggregateID() uuid.UUID
- func (a *BaseAggregate) AggregateType() cqrs.AggregateType
- func (a *BaseAggregate) Changes() []cqrs.Event
- func (a *BaseAggregate) CurrentVersion() int
- func (a *BaseAggregate) FlushChanges()
- func (a *BaseAggregate) NewEvent(typ cqrs.EventType, data cqrs.EventData) cqrs.Event
- func (a *BaseAggregate) NewEventWithTime(typ cqrs.EventType, data cqrs.EventData, time time.Time) cqrs.Event
- func (a *BaseAggregate) OriginalVersion() int
- func (a *BaseAggregate) TrackChange(events ...cqrs.Event)
- type IllegalVersionError
- type SnapshotConfig
- type SnapshotError
- type SnapshotOption
- type UnregisteredError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyEvent ¶
ApplyEvent ...
func ApplyEvents ¶
ApplyEvents ...
func ApplyHistory ¶
func ApplyHistory(aggregate cqrs.Aggregate, events ...cqrs.Event) error
ApplyHistory ...
func Repository ¶
func Repository(eventStore cqrs.EventStore, aggregateCfg cqrs.AggregateConfig) cqrs.AggregateRepository
Repository ...
func Snapshotter ¶
func Snapshotter(aggregates cqrs.AggregateRepository, cfg SnapshotConfig, snapshots cqrs.SnapshotRepository) cqrs.AggregateRepository
Snapshotter ...
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 ¶
SnapshotConfig ...
func ConfigureSnapshots ¶
func ConfigureSnapshots(options ...SnapshotOption) SnapshotConfig
ConfigureSnapshots ...
type SnapshotError ¶
SnapshotError ...
func (SnapshotError) Error ¶
func (err SnapshotError) Error() string
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