Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Aggregate ¶
type Aggregate interface { AggregateID() Identifier AggregateType() string }
Aggregate represents a cluster of related objects that can be treated as a single unit.
This basic interface is intended for simple aggregates that may not follow CQRS or event sourcing patterns.
type AggregateFactory ¶
type AggregateFactory interface { RegisterAggregate(aggregateType string, factory FactoryFn) CreateAggregate(aggregateType string, ID Identifier) (ESAggregate, error) }
AggregateFactory is responsible for creating aggregates. It registers aggregate factory functions and creates aggregates based on a given aggregate type and identifier.
type Command ¶
type Command interface { AggregateID() Identifier AggregateType() string CommandType() string }
Command is sent to the domain to change the state of an aggregate.
Commands are named with a verb in the imperative mood, e.g., ConfirmOrder.
type CommandHandler ¶
type CommandHandler interface {
Handle(c Command) ([]DomainEvent, error)
}
CommandHandler is responsible for executing commands.
It processes a command, produces relevant domain events.
It returns a list of domain events on success It returns an error if the command cannot be executed.
type CommandHandlerFunc ¶
type CommandHandlerFunc func(Command) ([]DomainEvent, error)
CommandHandlerFunc is a function type that can be used as a command handler.
type DomainEvent ¶
type DomainEvent interface {
EventType() string
}
DomainEvent represents an event that has occurred in the domain.
Events are named with a past-participle verb, e.g., OrderConfirmed.
type ESAggregate ¶ added in v0.6.0
type ESAggregate interface { Aggregate Versionable CommandHandler EventApplier }
ESAggregate represents an aggregate that is designed with CQRS and event sourcing in mind.
It extends the basic Aggregate interface and includes additional responsibilities such as command handling, event application, and versioning.
type EventApplier ¶ added in v0.5.0
type EventApplier interface {
Apply(e ...DomainEvent) error
}
EventApplier is responsible for applying domain events to an aggregate.
type EventApplierFunc ¶ added in v0.5.0
type EventApplierFunc func(DomainEvent)
EventApplierFunc is a function type that can be used as an event applier.
type EventMatcher ¶ added in v0.5.0
type EventMatcher func(DomainEvent) bool
EventMatcher is a func that can match event to a criteria.
func MatchAnyEventOf ¶ added in v0.5.0
func MatchAnyEventOf(types ...string) EventMatcher
MatchAnyEventOf matches if any of several matchers matches.
func MatchEvent ¶ added in v0.5.0
func MatchEvent(t string) EventMatcher
MatchEvent matches a specific event type, nil events never match.
type FactoryFn ¶ added in v0.5.0
type FactoryFn func(Identifier) ESAggregate
FactoryFn is a function type for an aggregate factory function.
type Identifier ¶ added in v0.5.0
Identifier represents an aggregate identifier.
type Versionable ¶ added in v0.5.0
type Versionable interface {
Version() int
}
Versionable indicates that an object can support different versions.
Directories
¶
Path | Synopsis |
---|---|
Package aggregate provides a base implementation for event sourced aggregates.
|
Package aggregate provides a base implementation for event sourced aggregates. |
examples
|
|