evoq_adapter behaviour (evoq v1.12.0)

View Source

Event store adapter behavior for evoq

Defines the interface for event store operations. Implementations provide the actual connection to an event store backend.

Implementing an Adapter

  -module(my_adapter).
  -behaviour(evoq_adapter).
 
  append(StoreId, StreamId, ExpectedVersion, Events) ->
      %% Implementation here
      {ok, NewVersion}.

Configuration

Set the adapter in application config:

  {evoq, [
      {event_store_adapter, my_adapter}
  ]}

Summary

Callbacks

append/4

-callback append(StoreId :: atom(), StreamId :: binary(), ExpectedVersion :: integer(), Events :: [map()]) ->
                    {ok, non_neg_integer()} | {error, term()}.

delete_stream/2

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

exists/2

-callback exists(StoreId :: atom(), StreamId :: binary()) -> boolean().

list_streams/1

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

read/5

-callback read(StoreId :: atom(),
               StreamId :: binary(),
               StartVersion :: non_neg_integer(),
               Count :: pos_integer(),
               Direction :: forward | backward) ->
                  {ok, [evoq_event()]} | {error, term()}.

read_all/3

-callback read_all(StoreId :: atom(), StreamId :: binary(), Direction :: forward | backward) ->
                      {ok, [evoq_event()]} | {error, term()}.

read_all_global/3

(optional)
-callback read_all_global(StoreId :: atom(), Offset :: non_neg_integer(), BatchSize :: pos_integer()) ->
                             {ok, [evoq_event()]} | {error, term()}.

read_by_event_types/3

-callback read_by_event_types(StoreId :: atom(), EventTypes :: [binary()], BatchSize :: pos_integer()) ->
                                 {ok, [evoq_event()]} | {error, term()}.

version/2

-callback version(StoreId :: atom(), StreamId :: binary()) -> integer().