Raxol.Architecture.EventSourcing.EventStore (Raxol v2.0.1)

View Source

Event store implementation for event sourcing pattern.

Provides functionality to store, retrieve, and subscribe to events in a functional programming style.

Summary

Functions

Append a single event to a stream.

Append multiple events to a stream (with server name as first argument).

Returns a specification to start this module under a supervisor.

Delete a stream (soft delete).

Get event store statistics.

Get stream information.

Read all events across all streams.

Starts the event store.

Subscribe to events from a stream or all events.

Types

event()

@type event() :: %{
  id: binary(),
  stream_name: binary(),
  event_type: binary(),
  data: map(),
  metadata: map(),
  timestamp: DateTime.t(),
  version: non_neg_integer()
}

event_id()

@type event_id() :: binary()

stream_name()

@type stream_name() :: binary()

version()

@type version() :: non_neg_integer()

Functions

append_event(event, stream_name, context \\ %{})

Append a single event to a stream.

append_events(events, stream_name, expected_version \\ :any)

Append multiple events to a stream.

append_events(server, events, stream_name, context)

Append multiple events to a stream (with server name as first argument).

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

delete_stream(stream_name)

Delete a stream (soft delete).

get_statistics()

Get event store statistics.

get_stream_info(stream_name)

Get stream information.

read_all_events(start_id \\ 0, count \\ :all)

Read all events across all streams.

read_stream(stream_name, start_version \\ 0, count \\ :all)

Read events from a stream.

start_link(opts \\ [])

Starts the event store.

subscribe(subscriber_pid, stream_name \\ :all, options \\ [])

Subscribe to events from a stream or all events.

unsubscribe(subscriber_pid, stream_name \\ :all)

Unsubscribe from events.