Raxol.Storage.EventStorage behaviour (Raxol v2.0.1)
View SourceStorage interface for event sourcing system.
This module defines the behavior for event storage implementations and provides a unified interface for storing and retrieving events.
Summary
Functions
Appends an event to the specified stream.
Appends multiple events to the specified stream.
Lists all available streams.
Loads the latest snapshot for a stream.
Reads all events across all streams.
Reads events from a specific stream.
Saves a snapshot for a stream.
Types
@type event() :: Raxol.Architecture.EventSourcing.Event.t()
@type position() :: non_neg_integer()
@type stream_name() :: String.t()
@type version() :: non_neg_integer()
Callbacks
@callback append_event( storage :: term(), event :: event(), stream_name :: stream_name() ) :: {:ok, String.t()} | {:error, term()}
@callback append_events( storage :: term(), events :: [event()], stream_name :: stream_name() ) :: {:ok, [String.t()]} | {:error, term()}
@callback list_streams(storage :: term()) :: {:ok, [Raxol.Architecture.EventSourcing.EventStream.t()]} | {:error, term()}
@callback load_snapshot(storage :: term(), stream_name :: stream_name()) :: {:ok, term()} | {:error, term()}
@callback read_all( storage :: term(), start_position :: position(), count :: pos_integer() ) :: {:ok, [event()]} | {:error, term()}
@callback read_stream( storage :: term(), stream_name :: stream_name(), start_position :: position(), count :: pos_integer() ) :: {:ok, [event()]} | {:error, term()}
Functions
Appends an event to the specified stream.
Appends multiple events to the specified stream.
Lists all available streams.
Loads the latest snapshot for a stream.
Reads all events across all streams.
Reads events from a specific stream.
Saves a snapshot for a stream.