Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNilAggregateStore = errors.New("aggregate store is nil")
ErrNilAggregateStore is when a dispatcher is created with a nil aggregate store.
Functions ¶
This section is empty.
Types ¶
type CommandHandler ¶
type CommandHandler struct {
// contains filtered or unexported fields
}
CommandHandler dispatches commands to an aggregate.
The dispatch process is as follows: 1. The handler receives a command. 2. An aggregate is created or loaded using an aggregate store. 3. The aggregate's command handler is called. 4. The aggregate stores events in response to the command. 5. The new events are stored in the event store. 6. The events are published on the event bus after a successful store.
func NewCommandHandler ¶
func NewCommandHandler(t eh.AggregateType, store eh.AggregateStore) (*CommandHandler, error)
NewCommandHandler creates a new CommandHandler for an aggregate type.
func (*CommandHandler) HandleCommand ¶
HandleCommand handles a command with the registered aggregate. Returns ErrAggregateNotFound if no aggregate could be found.