evoq_pm_instance (evoq v1.30.1)
View SourceProcess manager instance GenServer.
Represents a single running instance of a process manager. Each instance: - Has a unique process ID (correlation ID) - Maintains its own state - Handles events and dispatches commands - Supports compensation on a failed command
Summary
Functions
Trigger compensation for a failed command.
Get the current state.
Handle an event.
Start a PM instance.
Functions
-spec compensate(pid(), #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, [#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}]} | skip.
Trigger compensation for a failed command.
Get the current state.
-spec handle_event(pid(), map(), map()) -> ok | {ok, [{ok, non_neg_integer(), [map()]} | {error, term()}]} | {error, term()}.
Handle an event.
{ok, Results} carries one entry per command the process manager dispatched, in order, plus one per compensating command if a dispatch failed, so the list can be shorter than the commands the PM returned.
Start a PM instance.