evoq_subscription_adapter behaviour (evoq v1.14.1)

View Source

Subscription adapter behavior for evoq

Defines the interface for subscription operations. Subscriptions enable event handlers to receive events as they are appended.

Supports multiple subscription types: - stream: Subscribe to events from a specific stream - event_type: Subscribe to events of a specific type (across all streams) - event_pattern: Subscribe using wildcard patterns - event_payload: Subscribe based on event payload content

Summary

Types

start_from/0

-type start_from() :: origin | current | {position, non_neg_integer()}.

Callbacks

ack/4

-callback ack(StoreId :: atom(),
              SubscriptionName :: binary(),
              StreamId :: binary() | undefined,
              Position :: non_neg_integer()) ->
                 ok | {error, term()}.

get_by_name/2

-callback get_by_name(StoreId :: atom(), SubscriptionName :: binary()) ->
                         {ok, evoq_subscription()} | {error, not_found | term()}.

get_checkpoint/2

-callback get_checkpoint(StoreId :: atom(), SubscriptionName :: binary()) ->
                            {ok, non_neg_integer()} | {error, not_found | term()}.

list/1

-callback list(StoreId :: atom()) -> {ok, [evoq_subscription()]} | {error, term()}.

subscribe/5

-callback subscribe(StoreId :: atom(),
                    Type :: evoq_subscription_type(),
                    Selector :: binary() | map(),
                    SubscriptionName :: binary(),
                    Opts :: map()) ->
                       {ok, binary()} | {error, term()}.

unsubscribe/2

-callback unsubscribe(StoreId :: atom(), SubscriptionId :: binary()) -> ok | {error, term()}.