commanded v0.8.5 Commanded.Commands.Handler behaviour

Summary

Callbacks

Apply the given command to the event-sourced aggregate root

Types

aggregate_root()
aggregate_root() :: struct
command()
command() :: struct
reason()
reason() :: term

Callbacks

handle(aggregate_root, command)
handle(aggregate_root, command) ::
  {:ok, aggregate_root} |
  {:error, reason}

Apply the given command to the event-sourced aggregate root.

You must return {:ok, aggregate} with the updated aggregate root on success. This is the struct containing the aggregate's uuid, pending events, and current version.

You should return {:error, reason} on failure.