View Source Eventize.Persistence.EventStore behaviour (eventize v0.2.0)

EventStore is a GenServer process used to store events for Eventize.EventSourcedProcess instances.

Link to this section Summary

Types

A map containing all data needed to append events to the event store.

A map containing all data needed to append a snapshot to the event store.

A map containing all data needed to delete events from the event store.

Represents the response a caller will receive when deleting events or snapshots.

A map containing all data needed to delete snapshots from the event store.

Represents the response that a caller will receive when reading or appending events.

A map containing all data needed to get events from the event store.

A map containing all data needed to load a snapshot from the event store.

Represents the response that a caller will receive when reading or appending a snapshot.

Link to this section Types

Link to this type

append_events_command()

View Source
@type append_events_command() :: %{
  stream_name: String.t(),
  events: [{term(), map()}],
  expected_version: :any | :empty | non_neg_integer()
}

A map containing all data needed to append events to the event store.

Link to this type

append_snapshot_command()

View Source
@type append_snapshot_command() :: %{
  stream_name: String.t(),
  snapshot: {term(), map()},
  version: non_neg_integer()
}

A map containing all data needed to append a snapshot to the event store.

Link to this type

delete_events_command()

View Source
@type delete_events_command() :: %{
  stream_name: String.t(),
  version: non_neg_integer() | :all
}

A map containing all data needed to delete events from the event store.

@type delete_response() :: :ok | {:error, term()}

Represents the response a caller will receive when deleting events or snapshots.

Link to this type

delete_snapshots_command()

View Source
@type delete_snapshots_command() :: %{
  stream_name: String.t(),
  version: non_neg_integer() | :all
}

A map containing all data needed to delete snapshots from the event store.

@type event_bus() :: %{
  load_events:
    (String.t(), :start | non_neg_integer(), :all | non_neg_integer() ->
       events_response()),
  append_events:
    (String.t(), [{term(), map()}], :any | :empty | non_neg_integer() ->
       events_response()),
  delete_events: (String.t(), non_neg_integer() -> delete_response()),
  load_snapshot: (String.t(), :max | non_neg_integer() -> snapshot_response()),
  append_snapshot:
    (String.t(), {term(), map()}, non_neg_integer() -> snapshot_response()),
  delete_snapshots: (String.t(), non_neg_integer() -> delete_response())
}
@type events_response() ::
  {:ok, [Eventize.Persistence.EventStore.EventData], :empty | non_neg_integer()}
  | {:error, term()}

Represents the response that a caller will receive when reading or appending events.

@type load_events_query() :: %{
  stream_name: String.t(),
  start: :start | non_neg_integer(),
  max_count: :all | non_neg_integer()
}

A map containing all data needed to get events from the event store.

@type load_snapshot_query() :: %{
  stream_name: String.t(),
  max_version: :max | non_neg_integer()
}

A map containing all data needed to load a snapshot from the event store.

@type snapshot_response() ::
  {:ok,
   %Eventize.Persistence.EventStore.SnapshotData{
     meta_data: term(),
     payload: term(),
     version: term()
   }
   | nil}
  | {:error, term()}

Represents the response that a caller will receive when reading or appending a snapshot.

Link to this section Callbacks

Link to this callback

append_events(append_events_command, from, term)

View Source
@callback append_events(append_events_command(), GenServer.from(), term()) ::
  {:reply, events_response(), term()}
  | {:reply, events_response(), term(),
     timeout() | :hibernate | {:continue, continue_arg :: term()}}
  | {:stop, term(), term(), term()}
  | {:stop, term(), term()}
Link to this callback

append_snapshot(append_snapshot_command, from, term)

View Source
@callback append_snapshot(append_snapshot_command(), GenServer.from(), term()) ::
  {:reply, snapshot_response(), term()}
  | {:reply, snapshot_response(), term(),
     timeout() | :hibernate | {:continue, continue_arg :: term()}}
  | {:stop, term(), term(), term()}
  | {:stop, term(), term()}
Link to this callback

delete_events(delete_events_command, from, term)

View Source
@callback delete_events(delete_events_command(), GenServer.from(), term()) ::
  {:reply, delete_response(), term()}
  | {:reply, delete_response(), term(),
     timeout() | :hibernate | {:continue, continue_arg :: term()}}
  | {:stop, term(), term(), term()}
  | {:stop, term(), term()}
Link to this callback

delete_snapshots(delete_snapshots_command, from, term)

View Source
@callback delete_snapshots(delete_snapshots_command(), GenServer.from(), term()) ::
  {:reply, delete_response(), term()}
  | {:reply, delete_response(), term(),
     timeout() | :hibernate | {:continue, continue_arg :: term()}}
  | {:stop, term(), term(), term()}
  | {:stop, term(), term()}
Link to this callback

load_events(load_events_query, from, term)

View Source
@callback load_events(load_events_query(), GenServer.from(), term()) ::
  {:reply, events_response(), term()}
  | {:reply, events_response(), term(),
     timeout() | :hibernate | {:continue, continue_arg :: term()}}
  | {:stop, term(), term(), term()}
  | {:stop, term(), term()}
Link to this callback

load_snapshot(load_snapshot_query, from, term)

View Source
@callback load_snapshot(load_snapshot_query(), GenServer.from(), term()) ::
  {:reply, snapshot_response(), term()}
  | {:reply, snapshot_response(), term(),
     timeout() | :hibernate | {:continue, continue_arg :: term()}}
  | {:stop, term(), term(), term()}
  | {:stop, term(), term()}

Link to this section Functions

@spec parse_event_bus(any()) :: event_bus()