evoq_consistency (evoq v1.5.0)

View Source

Consistency modes for command dispatch.

Supports: - eventual: Return immediately after events are persisted - strong: Wait for all handlers to process events - {handlers, [atom()]}: Wait for specific handlers

Uses pg for handler acknowledgment tracking.

Strong Consistency Flow

1. Command dispatched, events persisted 2. Dispatcher calls wait_for/4 3. Event handlers process events 4. Handlers call acknowledge/4 after processing 5. wait_for/4 returns when all required handlers ack

Summary

Functions

Acknowledge that a handler has processed events. Called by event handlers after processing.

Start the pg scope for consistency tracking.

Wait for handlers to process events up to the given version.

Functions

acknowledge(HandlerModule, StoreId, AggregateId, Version)

-spec acknowledge(atom(), atom(), binary(), non_neg_integer()) -> ok.

Acknowledge that a handler has processed events. Called by event handlers after processing.

start_pg()

-spec start_pg() -> ok.

Start the pg scope for consistency tracking.

wait_for(StoreId, AggregateId, Version, Opts)

-spec wait_for(atom(), binary(), non_neg_integer(), map()) -> ok | {error, timeout}.

Wait for handlers to process events up to the given version.