Documentation
¶
Index ¶
- type Aggregate
- type AggregateID
- type AggregateRoot
- type AggregateStore
- type ErrAggregateVersionConflict
- type ErrUnknownAggregateChangeType
- type ErrUnknownAggregateSnapshotType
- type Event
- type EventLoadHooks
- type EventRepository
- type EventSaveHooks
- type EventsPostLoad
- type EventsPostSave
- type EventsPreLoad
- type EventsPreSave
- type Hook
- func EventsPostLoadHook[K comparable](fn EventsPostLoad[K]) Hook[K]
- func EventsPostSaveHook[K comparable](fn EventsPostSave[K]) Hook[K]
- func EventsPreLoadHook[K comparable](fn EventsPreLoad[K]) Hook[K]
- func EventsPreSaveHook[K comparable](fn EventsPreSave[K]) Hook[K]
- func SnapshotPostLoadHook[K comparable](fn SnapshotPostLoad[K]) Hook[K]
- func SnapshotPostSaveHook[K comparable](fn SnapshotPostSave[K]) Hook[K]
- func SnapshotPreLoadHook[K comparable](fn SnapshotPreLoad[K]) Hook[K]
- func SnapshotPreSaveHook[K comparable](fn SnapshotPreSave[K]) Hook[K]
- type Hooks
- func (h Hooks[K]) EventsPostLoad(ctx context.Context, aggregate AggregateRoot[K], events []Event[K]) error
- func (h Hooks[K]) EventsPostSave(ctx context.Context, aggregate AggregateRoot[K], events []Event[K]) error
- func (h Hooks[K]) EventsPreLoad(ctx context.Context, aggregate AggregateRoot[K]) error
- func (h Hooks[K]) EventsPreSave(ctx context.Context, aggregate AggregateRoot[K], events []Event[K]) error
- func (h Hooks[K]) SnapshotPostLoad(ctx context.Context, aggregate AggregateRoot[K], snapshot *Snapshot[K]) error
- func (h Hooks[K]) SnapshotPostSave(ctx context.Context, aggregate AggregateRoot[K], snapshot Snapshot[K]) error
- func (h Hooks[K]) SnapshotPreLoad(ctx context.Context, aggregate AggregateRoot[K]) error
- func (h Hooks[K]) SnapshotPreSave(ctx context.Context, aggregate AggregateRoot[K], snapshot Snapshot[K]) error
- type Snapshot
- type SnapshotAggregate
- type SnapshotLoadHooks
- type SnapshotPostLoad
- type SnapshotPostSave
- type SnapshotPreLoad
- type SnapshotPreSave
- type SnapshotRepository
- type SnapshotSaveHooks
- type SnapshotStrategy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Aggregate ¶
type Aggregate[K comparable] interface { AggregateID() K AggregateVersion() int TrackChange(aggregate AggregateRoot[K], event any) error Changes() []any SetID(K) SetVersion(int) // contains filtered or unexported methods }
func NewAggregate ¶
func NewAggregate[K comparable](id AggregateID[K]) Aggregate[K]
type AggregateID ¶
type AggregateID[K comparable] interface { Get() K // Get the current ID; this can return a zero value and IsSet should be used to check for zero values New() K // Generate new ID based on type-specific rules Set(K) // Set the ID if it is not already set IsSet() bool // Check against type-specific zero value rules }
type AggregateRoot ¶
type AggregateRoot[K comparable] interface { Aggregate[K] AggregateType() string ApplyChange(event any) error }
type AggregateStore ¶
type AggregateStore[K comparable] interface { Load(ctx context.Context, aggregate AggregateRoot[K], hooks ...Hook[K]) error Save(ctx context.Context, aggregate AggregateRoot[K], hooks ...Hook[K]) error }
func NewEventStore ¶
func NewEventStore[K comparable]( registry envelope.Registry, repository EventRepository[K], ) AggregateStore[K]
func NewSnapshotStore ¶
func NewSnapshotStore[K comparable]( registry envelope.Registry, eventStore AggregateStore[K], repository SnapshotRepository[K], strategy SnapshotStrategy[K], ) AggregateStore[K]
type ErrAggregateVersionConflict ¶
type ErrAggregateVersionConflict struct {
AggregateID any
AggregateType string
AggregateVersion int
}
func (ErrAggregateVersionConflict) Error ¶
func (e ErrAggregateVersionConflict) Error() string
type ErrUnknownAggregateChangeType ¶
func (ErrUnknownAggregateChangeType) Error ¶
func (e ErrUnknownAggregateChangeType) Error() string
type ErrUnknownAggregateSnapshotType ¶
func (ErrUnknownAggregateSnapshotType) Error ¶
func (e ErrUnknownAggregateSnapshotType) Error() string
type EventLoadHooks ¶
type EventRepository ¶
type EventSaveHooks ¶
type EventsPostLoad ¶
type EventsPostLoad[K comparable] func(ctx context.Context, aggregate AggregateRoot[K], events []Event[K]) error
type EventsPostSave ¶
type EventsPostSave[K comparable] func(ctx context.Context, aggregate AggregateRoot[K], events []Event[K]) error
type EventsPreLoad ¶
type EventsPreLoad[K comparable] func(ctx context.Context, aggregate AggregateRoot[K]) error
type EventsPreSave ¶
type EventsPreSave[K comparable] func(ctx context.Context, aggregate AggregateRoot[K], events []Event[K]) error
type Hook ¶
type Hook[K comparable] interface { EventSaveHooks[K] EventLoadHooks[K] SnapshotSaveHooks[K] SnapshotLoadHooks[K] }
func EventsPostLoadHook ¶
func EventsPostLoadHook[K comparable](fn EventsPostLoad[K]) Hook[K]
func EventsPostSaveHook ¶
func EventsPostSaveHook[K comparable](fn EventsPostSave[K]) Hook[K]
func EventsPreLoadHook ¶
func EventsPreLoadHook[K comparable](fn EventsPreLoad[K]) Hook[K]
func EventsPreSaveHook ¶
func EventsPreSaveHook[K comparable](fn EventsPreSave[K]) Hook[K]
func SnapshotPostLoadHook ¶
func SnapshotPostLoadHook[K comparable](fn SnapshotPostLoad[K]) Hook[K]
func SnapshotPostSaveHook ¶
func SnapshotPostSaveHook[K comparable](fn SnapshotPostSave[K]) Hook[K]
func SnapshotPreLoadHook ¶
func SnapshotPreLoadHook[K comparable](fn SnapshotPreLoad[K]) Hook[K]
func SnapshotPreSaveHook ¶
func SnapshotPreSaveHook[K comparable](fn SnapshotPreSave[K]) Hook[K]
type Hooks ¶
type Hooks[K comparable] []Hook[K]
func (Hooks[K]) EventsPostLoad ¶
func (Hooks[K]) EventsPostSave ¶
func (Hooks[K]) EventsPreLoad ¶
func (Hooks[K]) EventsPreSave ¶
func (Hooks[K]) SnapshotPostLoad ¶
func (Hooks[K]) SnapshotPostSave ¶
func (Hooks[K]) SnapshotPreLoad ¶
type SnapshotAggregate ¶
type SnapshotAggregate[K comparable] interface { CreateSnapshot() any ApplySnapshot(snapshot any) error Aggregate[K] }
type SnapshotLoadHooks ¶
type SnapshotPostLoad ¶
type SnapshotPostLoad[K comparable] func(ctx context.Context, aggregate AggregateRoot[K], snapshot *Snapshot[K]) error
type SnapshotPostSave ¶
type SnapshotPostSave[K comparable] func(ctx context.Context, aggregate AggregateRoot[K], snapshot Snapshot[K]) error
type SnapshotPreLoad ¶
type SnapshotPreLoad[K comparable] func(ctx context.Context, aggregate AggregateRoot[K]) error
type SnapshotPreSave ¶
type SnapshotPreSave[K comparable] func(ctx context.Context, aggregate AggregateRoot[K], snapshot Snapshot[K]) error
type SnapshotRepository ¶
type SnapshotSaveHooks ¶
type SnapshotStrategy ¶
type SnapshotStrategy[K comparable] interface { ShouldSnapshot(aggregate AggregateRoot[K]) bool }
func NewFrequencySnapshotStrategy ¶
func NewFrequencySnapshotStrategy[K comparable](frequency int) SnapshotStrategy[K]
NewFrequencySnapshotStrategy creates a new SnapshotStrategy that takes in a frequency value.
This strategy is useful when you want to snapshot the aggregate every N changes.
func NewParticularChangesSnapshotStrategy ¶
func NewParticularChangesSnapshotStrategy[K comparable](changes []any) SnapshotStrategy[K]
NewParticularChangesSnapshotStrategy creates a new SnapshotStrategy that takes in a list of changes.
This strategy is useful when you want to snapshot the aggregate when a particular change is applied.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.