Orkestra.EventStore.EventStoreDB (orkestra v0.2.0)

Copy Markdown View Source

EventStoreDB adapter via Spear gRPC client.

Requires Spear.Connection in the supervision tree.

Configuration

config :orkestra, Orkestra.EventStore.EventStoreDB,
  connection_string: "esdb://localhost:2113?tls=false"

Summary

Functions

Subscribes subscriber to receive events from stream_id_or_all starting after from_position (exclusive).

Functions

subscribe_from_position(stream_id_or_all, from_position, subscriber)

@spec subscribe_from_position(
  Orkestra.EventStore.stream_id() | :all,
  integer(),
  pid()
) :: {:ok, reference()} | {:error, term()}

Subscribes subscriber to receive events from stream_id_or_all starting after from_position (exclusive).

Delegates to Spear.subscribe/4 with from: from_position. Spear's from: parameter is exclusive — it delivers events with position > from_position, matching the D-01 monotonic-integer contract and InMemory's semantics.

The subscriber process will receive Spear.Event.t() messages. Use global_position_from_spear_event/1 to extract the :global_position integer (mapped from commit_position) for checkpoint updates.

Phase 2 note: The live $all exclusive from: semantics and the commit_position integer mapping (RESEARCH.md A4/A5 — Open Question 1) are verified against a live EventStoreDB instance in Phase 2 integration tests. The Phase 1 test is compile/wiring-level only.

Returns {:ok, subscription_ref} on success or {:error, exception} on failure.