Helios v0.2.2 Helios.Aggregate behaviour View Source
Aggregate behaviour.
Once implemented add command mapping to router Helios.Router
.
Link to this section Summary
Callbacks
Applies single event to aggregate when replied or after handle_exec/3
is executed
Optional cllback, when implemented it should treansform offered snapshot into aggregate model
Handles execution of the command once command is handed from router to
Helios.Aggregate.Server
Constructs new instance of aggregate struct. Override to set defaults or if your struct is defined in different module
Returns unique identifier for stream to which events will be persisted
Optional callback, when implmented it should return snapshot of given aggregate
Link to this section Types
The unique aggregate id.
Link to this section Functions
Link to this section Callbacks
Applies single event to aggregate when replied or after handle_exec/3
is executed.
Must return {:ok, state}
if event is aplied or raise an error if failed.
Note that events should not be validated here, they must be respected since handle_execute/3
generated event and already validate it. Also, error has to bi risen in for some odd reason event cannot
be applied to aggregate.
Optional cllback, when implemented it should treansform offered snapshot into aggregate model.
Return {:ok, aggregate}
if snapshot is applied to aggregate, or
{:ignored, aggregate}
if you want ignore snapshot and apply all events from
beginning of the aggregate stream
handle(ctx :: Helios.Context.t(), params :: Helios.Context.params()) :: Helios.Context.t()
Handles execution of the command once command is handed from router to
Helios.Aggregate.Server
.
Constructs new instance of aggregate struct. Override to set defaults or if your struct is defined in different module.
Returns unique identifier for stream to which events will be persisted.
This persistance id will be used while persisting events emitted by aggregate into its own stream of the events.
Optional callback, when implmented it should return snapshot of given aggregate.
When snapshot is stored it should record among aggregate state, sequence number (or last_event_number) at which snapshot was taken.