Disco v0.1.3 Disco.EventStore View Source

The event store.

This module is responsible to manage events so that they can be persisted and then retrieved.

The actual implementation uses PostgreSQL and Ecto.SQL to store events. An adapter based approach has been planned as one of the next planned features.

Link to this section Summary

Functions

Adds an event to the store

Returns the offset of an event consumer

List events for a given aggregate id

List events for a given set of event types

List events after a given offset

Reset the offset of a given event consumer

Updates the offset of an event consumer

Link to this section Types

Link to this type event() View Source
event() :: %{:type => binary(), optional(atom()) => any()}

Link to this section Functions

Link to this function emit(event) View Source
emit(event()) :: {:ok, result :: event()}

Adds an event to the store.

Link to this function event_consumer_offset(consumer) View Source
event_consumer_offset(consumer :: binary()) :: integer()

Returns the offset of an event consumer.

Link to this function list_events_for_aggregate_id(id) View Source
list_events_for_aggregate_id(aggregate_id :: binary()) :: [event()]

List events for a given aggregate id.

If offset is not present (nil), events will start from the beginning.

Link to this function list_events_with_types(types) View Source
list_events_with_types(event_types :: [binary()]) :: list()

List events for a given set of event types.

Link to this function load_events_after_offset(events_listened, offset) View Source
load_events_after_offset(events_listened :: [binary()], offset :: integer()) ::
  [map()]

List events after a given offset.

If offset is not present (nil), events will start from the beginning.

Link to this function reset_offsets_for_consumer(consumer) View Source
reset_offsets_for_consumer(binary()) :: any()

Reset the offset of a given event consumer.

Useful when you want a consumer to re-process all the events.

Link to this function update_event_consumer_offset(consumer, offset) View Source
update_event_consumer_offset(consumer :: binary(), offset :: integer()) ::
  {:ok, integer()}

Updates the offset of an event consumer.

This function is usually called after an event has been processed.