Documentation ¶
Overview ¶
Package es implements a common support for Event Sourcing.
To use, you should extend your Entity Aggregate from the AggregateBase struct.
Example:
package loans import ( "fmt" "github.com/AltScore/gothic/pkg/es" ) const EntityType = "loans" type Aggregate struct { es.AggregateBase[ID, Snapshot] }
Your events should extend the Event struct:
type flowStarted struct { es.Metadata ClientID ClientID TransactionID string TotalAmount Money }
Package samples contains sample code for using gothic.
Index ¶
- func Reify[Agg Aggregate[SS], SS Snapshot](previousEvents []event.Event, factory func(AggregateBase[SS]) Agg, ...) (Agg, error)
- type Aggregate
- type AggregateBase
- func (a *AggregateBase[SS]) Apply(e event.Event) error
- func (a *AggregateBase[SS]) GetNewEvents() []event.Event
- func (a *AggregateBase[SS]) HasEventsToSave() bool
- func (a *AggregateBase[SS]) ID() ids.ID
- func (a *AggregateBase[SS]) NewMetadata(eventType string) Metadata
- func (a *AggregateBase[SS]) Raise(e event.Event) error
- func (a *AggregateBase[SS]) Replay() error
- func (a *AggregateBase[SS]) SetId(id ids.ID)
- func (a *AggregateBase[SS]) Snapshot() SS
- func (a *AggregateBase[SS]) Type() string
- func (a *AggregateBase[SS]) Version() int
- func (a *AggregateBase[SS]) WithEventsSaved() AggregateBase[SS]
- type EntityID
- type Metadata
- type Option
- type Snapshot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AggregateBase ¶
type AggregateBase[SS Snapshot] struct { // contains filtered or unexported fields }
func (*AggregateBase[SS]) Apply ¶
func (a *AggregateBase[SS]) Apply(e event.Event) error
Apply process an already existent event to update the current Snapshot En error is returned in case the event is incorrect for this Snapshot
func (*AggregateBase[SS]) GetNewEvents ¶
func (a *AggregateBase[SS]) GetNewEvents() []event.Event
func (*AggregateBase[SS]) HasEventsToSave ¶ added in v0.2.0
func (a *AggregateBase[SS]) HasEventsToSave() bool
func (*AggregateBase[SS]) ID ¶ added in v0.1.4
func (a *AggregateBase[SS]) ID() ids.ID
func (*AggregateBase[SS]) NewMetadata ¶
func (a *AggregateBase[SS]) NewMetadata(eventType string) Metadata
func (*AggregateBase[SS]) Raise ¶
func (a *AggregateBase[SS]) Raise(e event.Event) error
Raise process a new event to update the current Snapshot and append it to the past events
func (*AggregateBase[SS]) Replay ¶
func (a *AggregateBase[SS]) Replay() error
func (*AggregateBase[SS]) SetId ¶
func (a *AggregateBase[SS]) SetId(id ids.ID)
func (*AggregateBase[SS]) Snapshot ¶
func (a *AggregateBase[SS]) Snapshot() SS
func (*AggregateBase[SS]) Type ¶ added in v0.2.0
func (a *AggregateBase[SS]) Type() string
func (*AggregateBase[SS]) Version ¶
func (a *AggregateBase[SS]) Version() int
func (*AggregateBase[SS]) WithEventsSaved ¶ added in v0.7.1
func (a *AggregateBase[SS]) WithEventsSaved() AggregateBase[SS]
type Metadata ¶
type Metadata struct {
// contains filtered or unexported fields
}
func NewMetadata ¶
func (*Metadata) EntityType ¶
type Option ¶ added in v0.2.0
type Option[SS Snapshot] func(*AggregateBase[SS])
func WithSnapshot ¶ added in v0.2.0
Click to show internal directories.
Click to hide internal directories.