Documentation
¶
Index ¶
- func Load(ctx context.Context, es core.EventStore, id string, a aggregate) error
- func LoadFromSnapshot(ctx context.Context, es core.EventStore, ss core.SnapshotStore, id string, ...) error
- func LoadSnapshot(ctx context.Context, ss core.SnapshotStore, id string, s snapshot) error
- func Register(a aggregate)
- func Save(es core.EventStore, a aggregate) error
- func SaveSnapshot(ss core.SnapshotStore, s snapshot) error
- func SetIDFunc(f func() string)
- func TrackChange(a aggregate, data interface{})
- func TrackChangeWithMetadata(a aggregate, data interface{}, metadata map[string]interface{})
- type RegisterFunc
- type Root
- type SnapshotMarshal
- type SnapshotUnmarshal
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadFromSnapshot ¶
func LoadFromSnapshot(ctx context.Context, es core.EventStore, ss core.SnapshotStore, id string, as aggregateSnapshot) error
LoadFromSnapshot fetch the aggregate by first get its snapshot and later append events after the snapshot was stored This can speed up the load time of aggregates with many events
func LoadSnapshot ¶
LoadSnapshot build the aggregate based on its snapshot data not including its events. Beware that it could be more events that has happened after the snapshot was taken
func Save ¶
func Save(es core.EventStore, a aggregate) error
Save stores the aggregate events in the supplied event store
func SaveSnapshot ¶
func SaveSnapshot(ss core.SnapshotStore, s snapshot) error
SaveSnapshot will only store the snapshot and will return an error if there are events that are not stored
func SetIDFunc ¶
func SetIDFunc(f func() string)
SetIDFunc is used to change how aggregate ID's are generated default is a random string
func TrackChange ¶
func TrackChange(a aggregate, data interface{})
TrackChange is used internally by behaviour methods to apply a state change to the current instance and also track it in order that it can be persisted later.
func TrackChangeWithMetadata ¶
func TrackChangeWithMetadata(a aggregate, data interface{}, metadata map[string]interface{})
TrackChangeWithMetadata is used internally by behaviour methods to apply a state change to the current instance and also track it in order that it can be persisted later. meta data is handled by this func to store none related application state
Types ¶
type RegisterFunc ¶
type RegisterFunc = func(events ...interface{})
type Root ¶
type Root struct {
// contains filtered or unexported fields
}
Root to be included into aggregates to give it the aggregate root behaviors
func (*Root) Events ¶
func (ar *Root) Events() []eventsourcing.Event
Events return the aggregate events from the aggregate make a copy of the slice preventing outsiders modifying events.
func (*Root) GlobalVersion ¶
func (ar *Root) GlobalVersion() eventsourcing.Version
GlobalVersion returns the global version based on the last stored event
func (*Root) UnsavedEvents ¶
UnsavedEvents return true if there's unsaved events on the aggregate
func (*Root) Version ¶
func (ar *Root) Version() eventsourcing.Version
Version return the version based on events that are not stored