evoq_router (evoq v1.14.1)

View Source

Command router for evoq.

Routes commands to the appropriate aggregate based on aggregate_type and aggregate_id. Uses the dispatcher for middleware and execution.

Summary

Functions

Dispatch a command with default options.

Dispatch a command with options.

Functions

dispatch(Evoq_command)

-spec dispatch(#evoq_command{command_id :: binary() | undefined,
                             command_type :: atom() | undefined,
                             aggregate_type :: atom() | undefined,
                             aggregate_id :: binary() | undefined,
                             payload :: map(),
                             metadata :: map(),
                             causation_id :: binary() | undefined,
                             correlation_id :: binary() | undefined,
                             idempotency_key :: binary() | undefined}) ->
                  {ok, non_neg_integer(), [map()]} | {error, term()}.

Dispatch a command with default options.

dispatch(Evoq_command, Opts)

-spec dispatch(#evoq_command{command_id :: binary() | undefined,
                             command_type :: atom() | undefined,
                             aggregate_type :: atom() | undefined,
                             aggregate_id :: binary() | undefined,
                             payload :: map(),
                             metadata :: map(),
                             causation_id :: binary() | undefined,
                             correlation_id :: binary() | undefined,
                             idempotency_key :: binary() | undefined},
               map()) ->
                  {ok, non_neg_integer(), [map()]} | {error, term()}.

Dispatch a command with options.

Options: - consistency: eventual | strong | {handlers, [atom()]} - timeout: pos_integer() (milliseconds) - expected_version: integer() (-1 for any) - middleware: [atom()] (additional middleware)