Disco v0.1.3 Disco.EventStore.Client behaviour View Source

The Disco.EventStore.Client specification.

A client is used to interact with Disco.EventStore while keeping details isolated.

Like other components in Disco, even the Disco.EventStore.Client is built as a behaviour that implements default callbacks. This means that the simplest definition of a client can be achieved like the following:

defmodule MyApp.EventStoreClient do
  use Disco.EventStore.Client
end

Link to this section Summary

Callbacks

Called to emit an event to the event store

Called to obtain the current offset for a given cosumer. Returns 0 by default

Called to load events for a given aggregate id from event store

Called to load events to be consumed after a given offset

Called to load emitted events that need to be consumed

Called to update current offset counter

Link to this section Callbacks

Link to this callback emit(map) View Source
emit(map()) :: {:ok, event :: map()} | {:error, reason :: any()}

Called to emit an event to the event store.

Link to this callback get_consumer_offset(consumer) View Source
get_consumer_offset(consumer :: binary()) :: integer()

Called to obtain the current offset for a given cosumer. Returns 0 by default.

Link to this callback load_aggregate_events(id) View Source
load_aggregate_events(id :: any()) :: list()

Called to load events for a given aggregate id from event store.

Link to this callback load_events_after_offset(events_listened, offset) View Source
load_events_after_offset(events_listened :: [binary()], offset :: integer()) ::
  [map()]

Called to load events to be consumed after a given offset.

Link to this callback load_events_with_types(event_types) View Source
load_events_with_types(event_types :: [binary()]) :: list()

Called to load emitted events that need to be consumed.

Link to this callback update_consumer_offset(consumer, offset) View Source
update_consumer_offset(consumer :: binary(), offset :: integer()) ::
  {:ok, integer()}

Called to update current offset counter.