Packages
commanded
0.12.0
1.4.10
1.4.9
1.4.8
1.4.7
1.4.6
1.4.3
1.4.2
1.4.1
1.4.0
1.4.0-rc.0
1.3.1
1.3.0
1.2.0
1.1.1
1.1.0
1.0.1
1.0.0
1.0.0-rc.1
1.0.0-rc.0
0.19.1
0.19.0
0.18.1
0.18.0
0.17.5
0.17.4
0.17.3
0.17.2
0.17.1
0.17.0
0.16.0
0.16.0-rc.1
0.16.0-rc.0
0.15.1
0.15.0
0.14.0
0.14.0-rc.0
0.13.0
0.12.0
0.11.0
0.10.0
0.9.0
0.8.5
0.8.4
0.8.3
0.8.1
0.8.0
0.7.1
0.6.2
0.6.1
0.6.0
0.4.0
0.3.1
0.3.0
0.2.1
0.2.0
0.1.0
Use Commanded to build your own Elixir applications following the CQRS/ES pattern.
Current section
Files
Jump to
Current section
Files
lib/commanded/event_store/event_store.ex
defmodule Commanded.EventStore do
@moduledoc """
Defines the behaviour to be implemented by an event store adapter to be used by Commanded.
"""
alias Commanded.EventStore.{
EventData,
RecordedEvent,
SnapshotData,
}
defmacro __using__(_) do
adapter = Application.get_env(:commanded, :event_store_adapter, Commanded.EventStore.Adapters.InMemory)
quote do
@event_store unquote adapter
end
end
@type stream_uuid :: String.t
@type start_from :: :origin | :current | integer
@type stream_version :: integer
@type subscription_name :: String.t
@type source_uuid :: String.t
@type snapshot :: SnapshotData.t
@type reason :: term
@doc """
Append one or more events to a stream atomically.
"""
@callback append_to_stream(stream_uuid, expected_version :: non_neg_integer, events :: list(EventData.t)) :: {:ok, stream_version} | {:error, reason}
@doc """
Streams events from the given stream, in the order in which they were originally written.
"""
@callback stream_forward(stream_uuid, start_version :: non_neg_integer, read_batch_size :: non_neg_integer) :: Enumerable.t | {:error, :stream_not_found} | {:error, reason}
@doc """
Subscriber will be notified of every event persisted to any stream.
"""
@callback subscribe_to_all_streams(subscription_name, subscriber :: pid, start_from) :: {:ok, subscription :: pid}
| {:error, :subscription_already_exists}
| {:error, reason}
@doc """
Acknowledge receipt and successful processing of the given event received from a subscription to an event stream.
"""
@callback ack_event(pid, RecordedEvent.t) :: any
@doc """
Unsubscribe an existing subscriber from all event notifications.
"""
@callback unsubscribe_from_all_streams(subscription_name) :: :ok
@doc """
Read a snapshot, if available, for a given source.
"""
@callback read_snapshot(source_uuid) :: {:ok, snapshot} | {:error, :snapshot_not_found}
@doc """
Record a snapshot of the data and metadata for a given source
"""
@callback record_snapshot(snapshot) :: :ok | {:error, reason}
@doc """
Delete a previously recorded snapshop for a given source
"""
@callback delete_snapshot(source_uuid) :: :ok | {:error, reason}
end