Commanded v0.17.5 Commanded.EventStore behaviour View Source
Defines the behaviour to be implemented by an event store adapter to be used by Commanded.
Link to this section Summary
Functions
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
Delete a previously recorded snapshop for a given source
Get the configured event store adapter
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
Create a persistent subscription to all event streams
Unsubscribe an existing subscriber from all event notifications
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
Delete a previously recorded snapshop 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
Create a persistent subscription to all event streams
Unsubscribe an existing subscriber from all event notifications
Link to this section Types
reason()
View Source
reason() :: term()
reason() :: term()
snapshot()
View Source
snapshot() :: Commanded.EventStore.SnapshotData.t()
snapshot() :: Commanded.EventStore.SnapshotData.t()
source_uuid()
View Source
source_uuid() :: String.t()
source_uuid() :: String.t()
start_from()
View Source
start_from() :: :origin | :current | integer()
start_from() :: :origin | :current | integer()
stream_uuid()
View Source
stream_uuid() :: String.t()
stream_uuid() :: String.t()
stream_version()
View Source
stream_version() :: integer()
stream_version() :: integer()
subscription_name()
View Source
subscription_name() :: String.t()
subscription_name() :: String.t()
Link to this section Functions
ack_event(pid, event)
View Source
ack_event(pid(), Commanded.EventStore.RecordedEvent.t()) :: :ok
ack_event(pid(), Commanded.EventStore.RecordedEvent.t()) :: :ok
Acknowledge receipt and successful processing of the given event received from a subscription to an event stream.
append_to_stream(stream_uuid, expected_version, events)
View Source
append_to_stream(
stream_uuid(),
expected_version :: non_neg_integer(),
events :: [Commanded.EventStore.EventData.t()]
) ::
{:ok, stream_version()}
| {:error, :wrong_expected_version}
| {:error, reason()}
append_to_stream( stream_uuid(), expected_version :: non_neg_integer(), events :: [Commanded.EventStore.EventData.t()] ) :: {:ok, stream_version()} | {:error, :wrong_expected_version} | {:error, reason()}
Append one or more events to a stream atomically.
delete_snapshot(source_uuid)
View Source
delete_snapshot(source_uuid()) :: :ok | {:error, reason()}
delete_snapshot(source_uuid()) :: :ok | {:error, reason()}
Delete a previously recorded snapshop for a given source
event_store_adapter() View Source
Get the configured event store adapter
read_snapshot(source_uuid)
View Source
read_snapshot(source_uuid()) ::
{:ok, snapshot()} | {:error, :snapshot_not_found}
read_snapshot(source_uuid()) :: {:ok, snapshot()} | {:error, :snapshot_not_found}
Read a snapshot, if available, for a given source.
record_snapshot(snapshot) View Source
Record a snapshot of the data and metadata for a given source
stream_forward(stream_uuid, start_version \\ 0, read_batch_size \\ 1000)
View Source
stream_forward(
stream_uuid(),
start_version :: non_neg_integer(),
read_batch_size :: non_neg_integer()
) :: Enumerable.t() | {:error, :stream_not_found} | {:error, reason()}
stream_forward( stream_uuid(), start_version :: non_neg_integer(), read_batch_size :: non_neg_integer() ) :: Enumerable.t() | {:error, :stream_not_found} | {:error, reason()}
Streams events from the given stream, in the order in which they were originally written.
subscribe(stream_uuid)
View Source
subscribe(stream_uuid()) :: :ok | {:error, reason()}
subscribe(stream_uuid()) :: :ok | {:error, reason()}
Create a transient subscription to a single event stream.
subscribe_to_all_streams(subscription_name, subscriber, start_from)
View Source
subscribe_to_all_streams(
subscription_name(),
subscriber :: pid(),
start_from()
) ::
{:ok, subscription :: pid()}
| {:error, :subscription_already_exists}
| {:error, reason()}
subscribe_to_all_streams( subscription_name(), subscriber :: pid(), start_from() ) :: {:ok, subscription :: pid()} | {:error, :subscription_already_exists} | {:error, reason()}
Create a persistent subscription to all event streams.
unsubscribe_from_all_streams(subscription_name)
View Source
unsubscribe_from_all_streams(subscription_name()) :: :ok
unsubscribe_from_all_streams(subscription_name()) :: :ok
Unsubscribe an existing subscriber from all event notifications.
Link to this section Callbacks
ack_event(pid, arg1)
View Source
ack_event(pid(), Commanded.EventStore.RecordedEvent.t()) :: :ok
ack_event(pid(), Commanded.EventStore.RecordedEvent.t()) :: :ok
Acknowledge receipt and successful processing of the given event received from a subscription to an event stream.
append_to_stream(stream_uuid, expected_version, events)
View Source
append_to_stream(
stream_uuid(),
expected_version :: non_neg_integer(),
events :: [Commanded.EventStore.EventData.t()]
) ::
{:ok, stream_version()}
| {:error, :wrong_expected_version}
| {:error, reason()}
append_to_stream( stream_uuid(), expected_version :: non_neg_integer(), events :: [Commanded.EventStore.EventData.t()] ) :: {:ok, stream_version()} | {:error, :wrong_expected_version} | {:error, reason()}
Append one or more events to a stream atomically.
delete_snapshot(source_uuid)
View Source
delete_snapshot(source_uuid()) :: :ok | {:error, reason()}
delete_snapshot(source_uuid()) :: :ok | {:error, reason()}
Delete a previously recorded snapshop for a given source
read_snapshot(source_uuid)
View Source
read_snapshot(source_uuid()) ::
{:ok, snapshot()} | {:error, :snapshot_not_found}
read_snapshot(source_uuid()) :: {:ok, snapshot()} | {:error, :snapshot_not_found}
Read a snapshot, if available, for a given source.
record_snapshot(snapshot) View Source
Record a snapshot of the data and metadata for a given source
stream_forward(stream_uuid, start_version, read_batch_size)
View Source
stream_forward(
stream_uuid(),
start_version :: non_neg_integer(),
read_batch_size :: non_neg_integer()
) :: Enumerable.t() | {:error, :stream_not_found} | {:error, reason()}
stream_forward( stream_uuid(), start_version :: non_neg_integer(), read_batch_size :: non_neg_integer() ) :: Enumerable.t() | {:error, :stream_not_found} | {:error, reason()}
Streams events from the given stream, in the order in which they were originally written.
subscribe(stream_uuid)
View Source
subscribe(stream_uuid()) :: :ok | {:error, reason()}
subscribe(stream_uuid()) :: :ok | {:error, reason()}
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.
subscribe_to_all_streams(subscription_name, subscriber, start_from)
View Source
subscribe_to_all_streams(
subscription_name(),
subscriber :: pid(),
start_from()
) ::
{:ok, subscription :: pid()}
| {:error, :subscription_already_exists}
| {:error, reason()}
subscribe_to_all_streams( subscription_name(), subscriber :: pid(), start_from() ) :: {:ok, subscription :: pid()} | {:error, :subscription_already_exists} | {:error, reason()}
Create a persistent subscription to all event streams.
The event store will remember the subscribers last acknowledged event. Restarting the named subscription will resume from the next event following the last seen.
Once subscribed, the subscriber process should be sent a
{:subscribed, subscription} message to allow it to defer initialisation
until the subscription has started.
The subscriber process will be sent all events persisted to any stream. It
will receive a {:events, events} message for each batch of events persisted
for a single aggregate.
The subscriber must ack each received, and successfully processed event, using
Commanded.EventStore.ack_event/2.
unsubscribe_from_all_streams(subscription_name)
View Source
unsubscribe_from_all_streams(subscription_name()) :: :ok
unsubscribe_from_all_streams(subscription_name()) :: :ok
Unsubscribe an existing subscriber from all event notifications.