ExESDBGater.API (ex_esdb_gater v0.1.19)
The ExESDBGater.API GenServer acts as a simple high-availability proxy and load balancer for the GaterWorker processes in the cluster.
Summary
Functions
Acknowledge receipt of an event by a subscriber to persistent subscription.
Append events to a stream. ## Parameters
Returns a specification to start this module under a supervisor.
Gets a list of all gateway worker pids.
Get events from a stream, staring from a given version, in a given direction.
Get all streams from the store. ## Parameters
Get the subscriptions for a store.
Get the version of a stream.
List all managed stores in the cluster.
Gets a random pid of a gateway worker in the cluster.
Remove a permanent or transient subscription.
Get events from a stream, staring from a given version, backward. ## Parameters
Get events from a stream, staring from a given version, forward.
Types
Functions
@spec ack_event( store :: atom(), subscription_name :: String.t(), subscriber_pid :: pid(), event :: map() ) :: :ok | {:error, term()}
Acknowledge receipt of an event by a subscriber to persistent subscription.
@spec append_events( store :: atom(), stream_id :: stream(), events :: list() ) :: {:ok, integer()} | {:error, term()}
Append events to a stream. ## Parameters
Returns a specification to start this module under a supervisor.
See Supervisor
.
@spec delete_snapshot( store :: atom(), source_uuid :: binary(), stream_uuid :: binary(), version :: non_neg_integer() ) :: :ok
@spec gateway_worker_pids() :: list()
Gets a list of all gateway worker pids.
@spec get_events( store :: atom(), stream_id :: stream(), start_version :: integer(), count :: integer(), direction :: :forward | :backward ) :: {:ok, list()} | {:error, term()}
Get events from a stream, staring from a given version, in a given direction.
Get all streams from the store. ## Parameters
- store: the id of the store
## Returns
- a list of all streams in the store
Get the subscriptions for a store.
Get the version of a stream.
List all managed stores in the cluster.
## Returns
{:ok, stores_map}
containing store information{:error, reason}
if failed
@spec random_gateway_worker() :: pid()
Gets a random pid of a gateway worker in the cluster.
@spec record_snapshot( store :: atom(), source_uuid :: binary(), stream_uuid :: binary(), version :: non_neg_integer(), snapshot_record :: map() ) :: :ok
@spec remove_subscription( store :: any(), type :: subscription_type(), selector :: selector_type(), subscription_name :: subscription_name() ) :: :ok | {:error, error()}
Remove a permanent or transient subscription.
save_subscription(store, type, selector, subscription_name \\ "transient", start_from \\ 0, subscriber \\ nil)
@spec save_subscription( store :: atom(), type :: atom(), selector :: String.t() | map(), subscription_name :: String.t(), start_from :: non_neg_integer(), subscriber :: pid() | nil ) :: :ok
Description
Add a permanent or transient subscription.
Parameters
- store: the id of the store
- type: the type of subscription (:by_stream, :by_event_type, :by_event_pattern, :by_event_payload)
- selector: the selector for the subscription
($all, $<stream-id>, event-type (a string), or event-pattern)
- subscription_name: the name of the subscription, "transient" for a transient subscriptions, except for subscriptions :by_event_pattern or :by_event_payload
- start_from: the version to start from
- subscriber: the pid of the subscriber
@spec stream_backward( store :: atom(), stream_id :: stream(), start_version :: integer(), count :: non_neg_integer() ) :: {:ok, stream()} | {:error, term()}
Get events from a stream, staring from a given version, backward. ## Parameters
- store: the id of the store
- stream_id: the id of the stream
- start_version: the version to start from
- count: the number of events to return
## Returns
- a stream of events
@spec stream_forward( store :: atom(), stream_id :: stream(), start_version :: integer(), count :: integer() ) :: {:ok, stream()} | {:error, term()}
Get events from a stream, staring from a given version, forward.
## Parameters