Chronicle.EventSequences.EventSequence (cratis_chronicle v0.2.0)

Copy Markdown View Source

Represents a Chronicle event sequence.

Use this module when you want to work with a non-default event sequence and keep the event sequence identifier close to the append/query operations.

Summary

Functions

Appends a single event to the event sequence.

Appends multiple events to the event sequence.

Gets events for the given event source from the event sequence.

Gets the tail sequence number for the event sequence.

Checks whether the event sequence has events for the given event source id.

Creates an event sequence wrapper for the given event sequence id.

Gets a transactional view of the event sequence that buffers appends in the current unit of work.

Types

t()

@type t() :: %Chronicle.EventSequences.EventSequence{id: String.t(), opts: keyword()}

Functions

append(event_sequence, event_source_id, event, opts \\ [])

@spec append(t(), String.t(), struct(), keyword()) :: :ok | {:error, term()}

Appends a single event to the event sequence.

append_many(event_sequence, event_source_id, events, opts \\ [])

@spec append_many(t(), String.t(), [struct()], keyword()) :: :ok | {:error, term()}

Appends multiple events to the event sequence.

get_for_event_source(event_sequence, event_source_id, opts \\ [])

@spec get_for_event_source(t(), String.t(), keyword()) ::
  {:ok, list()} | {:error, term()}

Gets events for the given event source from the event sequence.

get_tail_sequence_number(event_sequence, event_source_id \\ nil, opts \\ [])

@spec get_tail_sequence_number(t(), String.t() | nil, keyword()) ::
  {:ok, non_neg_integer()} | {:error, term()}

Gets the tail sequence number for the event sequence.

has_events_for?(event_sequence, event_source_id, opts \\ [])

@spec has_events_for?(t(), String.t(), keyword()) ::
  {:ok, boolean()} | {:error, term()}

Checks whether the event sequence has events for the given event source id.

new(id, opts \\ [])

@spec new(
  String.t(),
  keyword()
) :: t()

Creates an event sequence wrapper for the given event sequence id.

transactional(event_sequence)

Gets a transactional view of the event sequence that buffers appends in the current unit of work.