eidetic v1.0.0-alpha2 Eidetic.EventStore behaviour

This module manages loading / saving from / to the EventStore.

Configuring:

confing :eidetic eventstore_adapter: Some.Adapter

Using:

{:ok, aggregate} = Eidetic.save(an_aggregate)

# or
aggregate = Eidetic.save!(aggregate)

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor

Load events from the EventStore and produce a aggregate, only returning the aggregate

Load events, to a particular version, from the EventStore and produce a aggregate, only returning the aggregate

Load events from the EventStore and produce an aggregate

Load events, to a particular version, from the EventStore and produce an aggregate

Save an %Eidetic.Aggregate{}’s uncommitted events to the EventStore, only returning the aggregate

Save an %Eidetic.Aggregate{}’s uncommitted events to the EventStore

Link to this section Functions

Link to this function add_subscriber(subscriber)
add_subscriber(atom()) :: any()
Link to this function child_spec(arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function load!(type, identifier)
load!(atom(), binary()) :: map()

Load events from the EventStore and produce a aggregate, only returning the aggregate.

Link to this function load!(type, identifier, list)

Load events, to a particular version, from the EventStore and produce a aggregate, only returning the aggregate.

Link to this function load(type, identifier)
load(atom(), binary()) :: {:ok, map()}

Load events from the EventStore and produce an aggregate

Link to this function load(type, identifier, list)

Load events, to a particular version, from the EventStore and produce an aggregate

Link to this function save!(aggregate)
save!(map()) :: map()

Save an %Eidetic.Aggregate{}’s uncommitted events to the EventStore, only returning the aggregate.

Eventually this will raise an error when a write / transaction fails.

Link to this function save(aggregate)
save(map()) :: {:ok, map()}

Save an %Eidetic.Aggregate{}’s uncommitted events to the EventStore

Link to this section Callbacks

Link to this callback handle_call({}, pid, atom)
handle_call(
  {:record,
   %Eidetic.Event{
     datetime: term(),
     identifier: term(),
     metadata: term(),
     payload: term(),
     serial_number: term(),
     type: term(),
     version: term()
   }},
  pid(),
  Map
) :: {:ok, [{:object_identifier, String.t()}]}
handle_call({:fetch, String.t()}, pid(), Map) ::
  {:ok,
   [
     {:events,
      [
        %Eidetic.Event{
          datetime: term(),
          identifier: term(),
          metadata: term(),
          payload: term(),
          serial_number: term(),
          type: term(),
          version: term()
        }
      ]}
   ]}
handle_call({:fetch_until, String.t(), pos_integer()}, pid(), Map) ::
  {:ok,
   [
     {:events,
      [
        %Eidetic.Event{
          datetime: term(),
          identifier: term(),
          metadata: term(),
          payload: term(),
          serial_number: term(),
          type: term(),
          version: term()
        }
      ]}
   ]}
Link to this callback handle_call({}, pid, atom)
handle_call(
  {:record,
   %Eidetic.Event{
     datetime: term(),
     identifier: term(),
     metadata: term(),
     payload: term(),
     serial_number: term(),
     type: term(),
     version: term()
   }},
  pid(),
  Map
) :: {:ok, [{:object_identifier, String.t()}]}
handle_call({:fetch, String.t()}, pid(), Map) ::
  {:ok,
   [
     {:events,
      [
        %Eidetic.Event{
          datetime: term(),
          identifier: term(),
          metadata: term(),
          payload: term(),
          serial_number: term(),
          type: term(),
          version: term()
        }
      ]}
   ]}
handle_call({:fetch_until, String.t(), pos_integer()}, pid(), Map) ::
  {:ok,
   [
     {:events,
      [
        %Eidetic.Event{
          datetime: term(),
          identifier: term(),
          metadata: term(),
          payload: term(),
          serial_number: term(),
          type: term(),
          version: term()
        }
      ]}
   ]}
Link to this callback handle_call({}, pid, atom)
handle_call(
  {:record,
   %Eidetic.Event{
     datetime: term(),
     identifier: term(),
     metadata: term(),
     payload: term(),
     serial_number: term(),
     type: term(),
     version: term()
   }},
  pid(),
  Map
) :: {:ok, [{:object_identifier, String.t()}]}
handle_call({:fetch, String.t()}, pid(), Map) ::
  {:ok,
   [
     {:events,
      [
        %Eidetic.Event{
          datetime: term(),
          identifier: term(),
          metadata: term(),
          payload: term(),
          serial_number: term(),
          type: term(),
          version: term()
        }
      ]}
   ]}
handle_call({:fetch_until, String.t(), pos_integer()}, pid(), Map) ::
  {:ok,
   [
     {:events,
      [
        %Eidetic.Event{
          datetime: term(),
          identifier: term(),
          metadata: term(),
          payload: term(),
          serial_number: term(),
          type: term(),
          version: term()
        }
      ]}
   ]}