Helios v0.1.0 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

Handles execution of the command

Returns unique identifier for stream to which events will be persisted

Link to this section Types

Link to this section Functions

Link to this section Callbacks

Link to this callback apply_event(event, aggregate) View Source
apply_event(event :: any(), aggregate :: Helios.Aggregate.t()) ::
  Helios.Aggregate.t() | no_return()

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.

Handles execution of the command.

Link to this callback persistance_id(id) View Source
persistance_id(id :: term()) :: String.t()

Returns unique identifier for stream to which events will be persisted.