Commanded.EventStore.Adapter behaviour (Commanded v1.3.1) View Source

Defines the behaviour to be implemented by an event store adapter to be used by Commanded.

Link to this section Summary

Callbacks

Acknowledge receipt and successful processing of the given event received from a subscription to an event stream.

Append one or more events to a stream atomically.

Return a child spec defining all processes required by the event store.

Delete a previously recorded snapshot for a given source

Read a snapshot, if available, for a given source.

Record a snapshot of the data and metadata for a given source

Streams events from the given stream, in the order in which they were originally written.

Create a transient subscription to a single event stream.

Unsubscribe an existing subscriber from event notifications.

Link to this section Types

Specs

adapter_meta() :: map()

Specs

application() :: Commanded.Application.t()

Specs

config() :: Keyword.t()

Specs

error() :: term()

Specs

expected_version() ::
  :any_version | :no_stream | :stream_exists | non_neg_integer()

Specs

options() :: Keyword.t()

Specs

source_uuid() :: String.t()

Specs

start_from() :: :origin | :current | integer()

Specs

stream_uuid() :: String.t()

Specs

subscriber() :: pid()

Specs

subscription() :: any()

Specs

subscription_name() :: String.t()

Link to this section Callbacks

Link to this callback

ack_event(adapter_meta, pid, t)

View Source

Specs

Acknowledge receipt and successful processing of the given event received from a subscription to an event stream.

Link to this callback

append_to_stream(adapter_meta, stream_uuid, expected_version, events)

View Source

Specs

append_to_stream(
  adapter_meta(),
  stream_uuid(),
  expected_version(),
  events :: [Commanded.EventStore.EventData.t()]
) :: :ok | {:error, :wrong_expected_version} | {:error, error()}

Append one or more events to a stream atomically.

Link to this callback

child_spec(application, config)

View Source

Specs

child_spec(application(), config()) ::
  {:ok, [:supervisor.child_spec() | {module(), term()} | module()],
   adapter_meta()}

Return a child spec defining all processes required by the event store.

Link to this callback

delete_snapshot(adapter_meta, source_uuid)

View Source

Specs

delete_snapshot(adapter_meta(), source_uuid()) :: :ok | {:error, error()}

Delete a previously recorded snapshot for a given source

Link to this callback

delete_subscription(adapter_meta, arg2, subscription_name)

View Source

Specs

delete_subscription(adapter_meta(), stream_uuid() | :all, subscription_name()) ::
  :ok | {:error, :subscription_not_found} | {:error, error()}

Delete an existing subscription.

Link to this callback

read_snapshot(adapter_meta, source_uuid)

View Source

Specs

read_snapshot(adapter_meta(), source_uuid()) ::
  {:ok, Commanded.EventStore.SnapshotData.t()} | {:error, :snapshot_not_found}

Read a snapshot, if available, for a given source.

Link to this callback

record_snapshot(adapter_meta, t)

View Source

Specs

record_snapshot(adapter_meta(), Commanded.EventStore.SnapshotData.t()) ::
  :ok | {:error, error()}

Record a snapshot of the data and metadata for a given source

Link to this callback

stream_forward(adapter_meta, stream_uuid, start_version, read_batch_size)

View Source

Specs

stream_forward(
  adapter_meta(),
  stream_uuid(),
  start_version :: non_neg_integer(),
  read_batch_size :: non_neg_integer()
) :: Enumerable.t() | {:error, :stream_not_found} | {:error, error()}

Streams events from the given stream, in the order in which they were originally written.

Link to this callback

subscribe(adapter_meta, arg2)

View Source

Specs

subscribe(adapter_meta(), stream_uuid() | :all) :: :ok | {:error, error()}

Create a transient subscription to a single event stream.

The event store will publish any events appended to the given stream to the subscriber process as an {:events, events} message.

The subscriber does not need to acknowledge receipt of the events.

Link to this callback

subscribe_to(adapter_meta, arg2, subscription_name, subscriber, start_from, options)

View Source

Specs

subscribe_to(
  adapter_meta(),
  stream_uuid() | :all,
  subscription_name(),
  subscriber(),
  start_from(),
  options()
) ::
  {:ok, subscription()}
  | {:error, :subscription_already_exists}
  | {:error, error()}

Create a persistent subscription to an event stream.

Link to this callback

unsubscribe(adapter_meta, subscription)

View Source

Specs

unsubscribe(adapter_meta(), subscription()) :: :ok

Unsubscribe an existing subscriber from event notifications.

This should not delete the subscription.