Maestro.Aggregate.CommandHandler behaviour (Maestro v0.5.0)
View SourceSimple behaviour for properly implementing command handlers the way that maestro expects. Its use is not required but is encouraged.
Summary
Callbacks
Command handlers in maestro should implement an eval function that expects
to receive the current Root object complete with sequence number and
aggregate ID and the incoming command. They should return a list of events or
raise an error which can be used to short circuit the command processing
cycle.
Types
@type command() :: Maestro.Types.Command.t()
@type root() :: Maestro.Aggregate.Root.t()
@type uncommitted_event() :: Maestro.Types.Event.uncommitted()
Callbacks
@callback eval(root(), command()) :: [uncommitted_event()]
Command handlers in maestro should implement an eval function that expects
to receive the current Root object complete with sequence number and
aggregate ID and the incoming command. They should return a list of events or
raise an error which can be used to short circuit the command processing
cycle.