ExESDB.EventStore (ex_esdb v0.0.4-alpha)

A GenServer wrapper around :khepri to act as an event store. Inspired by EventStoreDB's API.

Summary

Functions

Returns a specification to start this module under a supervisor.

Get the current state of the store.

Get the list of streams in the store.

Get the current version of a stream.

Functions

append_to_stream(store, stream_id, expected_version, events)

Append events to a stream.

Parameters

  • stream_id: The id of the stream to append to.
  • expected_version: The expected version of the stream (for optimistic concurrency).
  • events: A list of events to append.

Returns

  • {:ok, new_stream_version} if successful.
  • {:error, reason} if unsuccessful.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

get_state(store)

Get the current state of the store.

Parameters

  • store: The store to get the state of.

Returns

- `{:ok, state}`  if successful.
- `{:error, reason}` if unsuccessful.

get_streams(store)

Get the list of streams in the store.

Parameters

  • store: The store to get the streams from.

Returns

  • {:ok, streams} if successful.

read_stream_forward(store, stream_id, start_version, count)

Read events from a stream.

Parameters

  • stream_name: The name of the stream to read from.
  • start_version: The version to start reading from.
  • count: The number of events to read.

Returns

  • {:ok, events} if successful.
  • {:error, reason} if unsuccessful.

start_link(opts)

stream_version(store, stream_id)

Get the current version of a stream.

Parameters

  • stream_name: The name of the stream to check.

Returns

  • {:ok, version} if successful.
  • {:error, reason} if unsuccessful.