Commanded v0.15.0 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
Get the configured event store adapter
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 persistent subscription to all event streams
Unsubscribe an existing subscriber from all event notifications
Link to this section Types
Link to this section Functions
Get the configured event store adapter
Link to this section Callbacks
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 :: non_neg_integer(), events :: [Commanded.EventStore.EventData.t()]) :: {:ok, stream_version()} | {:error, reason()}
Append one or more events to a stream atomically.
delete_snapshot(source_uuid()) :: :ok | {:error, reason()}
Delete a previously recorded snapshop for a given source
read_snapshot(source_uuid()) :: {:ok, snapshot()} | {:error, :snapshot_not_found}
Read a snapshot, if available, for a given source.
Record a snapshot of the data and metadata for a given source
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_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.
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()) :: :ok
Unsubscribe an existing subscriber from all event notifications.