evoq_dispatcher (evoq v1.5.0)
View SourceCommand dispatcher with middleware pipeline.
Dispatches commands through the middleware chain to aggregates. Supports idempotency, retries, and consistency guarantees.
Dispatch Flow
1. Check idempotency cache 2. Create execution context 3. Run before_dispatch middleware 4. Get or start aggregate 5. Execute command on aggregate 6. Run after_dispatch or after_failure middleware 7. Handle consistency (wait for handlers if strong) 8. Cache result for idempotency
Summary
Functions
Dispatch a command through the middleware pipeline.
Functions
-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 through the middleware pipeline.
If command_id is undefined, auto-generates one. If idempotency_key is set, uses it for deduplication cache. Otherwise, command_id is used (each dispatch is unique).