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 a single event, then waits for every observer affected by the append to either reach the appended sequence number or fail.
Appends multiple events to the event sequence.
Appends a list of Chronicle.EventSequences.EventForEventSourceId entries as a
single atomic append-many, each carrying its own target event source id.
Appends events atomically and returns the detailed Chronicle.EventSequences.AppendResult.
Appends a prepare/3d event. See Chronicle.EventSequences.EventLog.append_prepared/3.
Appends a single event and returns the detailed Chronicle.EventSequences.AppendResult.
Completes a named, non-default stream so that no further events can be appended to it.
Gets events for the given event source from the event sequence.
Gets events from (and including) the given sequence number onward.
Reads the metadata of events by sequence number. See Chronicle.EventSequences.Streams.get_metadata/2.
Reads the metadata of a single event by sequence number. See
Chronicle.EventSequences.Streams.get_metadata_at/2.
Gets the sequence number that will be assigned to the next appended event.
Gets the tail sequence number for the event sequence.
Gets the tail sequence number scoped to only the event types the given reactor or reducer module subscribes to.
Checks whether the event sequence has events for the given event source id.
Creates an event sequence wrapper for the given event sequence id.
Serializes event once and returns a Chronicle.EventSequences.PreparedEvent bound to this
event sequence. See Chronicle.EventSequences.EventLog.prepare/2.
Redacts a single event at a specific sequence number.
Redacts all events for a given event source, optionally filtered to specific event types.
Gets a transactional view of the event sequence that buffers appends in the current unit of work.
Verifies that event is what was stored at sequence_number. See
Chronicle.EventSequences.Streams.verify_content/3.
Types
Functions
Appends a single event to the event sequence.
@spec append_and_wait_for_completion(t(), String.t(), struct(), keyword()) :: {:ok, %{success: boolean(), failed_partitions: list()}} | {:error, term()}
Appends a single event, then waits for every observer affected by the append to either reach the appended sequence number or fail.
Appends multiple events to the event sequence.
@spec append_many_for_event_sources( t(), [Chronicle.EventSequences.EventForEventSourceId.t()], keyword() ) :: :ok | {:error, term()}
Appends a list of Chronicle.EventSequences.EventForEventSourceId entries as a
single atomic append-many, each carrying its own target event source id.
@spec append_many_with_result(t(), String.t(), [struct()], keyword()) :: {:ok, Chronicle.EventSequences.AppendResult.t()} | {:error, term()}
Appends events atomically and returns the detailed Chronicle.EventSequences.AppendResult.
@spec append_prepared( t(), String.t(), Chronicle.EventSequences.PreparedEvent.t(), keyword() ) :: :ok | {:error, term()}
Appends a prepare/3d event. See Chronicle.EventSequences.EventLog.append_prepared/3.
@spec append_with_result(t(), String.t(), struct(), keyword()) :: {:ok, Chronicle.EventSequences.AppendResult.t()} | {:error, term()}
Appends a single event and returns the detailed Chronicle.EventSequences.AppendResult.
@spec complete_stream(t(), String.t(), String.t(), keyword()) :: {:ok, non_neg_integer()} | {:error, :default_stream_cannot_be_completed | :already_completed | term()}
Completes a named, non-default stream so that no further events can be appended to it.
Gets events for the given event source from the event sequence.
@spec get_from_sequence_number(t(), non_neg_integer(), keyword()) :: {:ok, list()} | {:error, term()}
Gets events from (and including) the given sequence number onward.
@spec get_metadata(t(), [non_neg_integer()], keyword()) :: {:ok, [map()]} | {:error, term()}
Reads the metadata of events by sequence number. See Chronicle.EventSequences.Streams.get_metadata/2.
@spec get_metadata_at(t(), non_neg_integer(), keyword()) :: {:ok, map()} | {:error, term()}
Reads the metadata of a single event by sequence number. See
Chronicle.EventSequences.Streams.get_metadata_at/2.
@spec get_next_sequence_number(t(), String.t() | nil, keyword()) :: {:ok, non_neg_integer()} | {:error, term()}
Gets the sequence number that will be assigned to the next appended event.
@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.
@spec get_tail_sequence_number_for_observer(t(), module(), keyword()) :: {:ok, non_neg_integer()} | {:error, term()}
Gets the tail sequence number scoped to only the event types the given reactor or reducer module subscribes to.
Checks whether the event sequence has events for the given event source id.
Creates an event sequence wrapper for the given event sequence id.
@spec prepare(t(), struct(), keyword()) :: {:ok, Chronicle.EventSequences.PreparedEvent.t()} | {:error, term()}
Serializes event once and returns a Chronicle.EventSequences.PreparedEvent bound to this
event sequence. See Chronicle.EventSequences.EventLog.prepare/2.
@spec redact(t(), non_neg_integer(), String.t(), keyword()) :: :ok | {:error, term()}
Redacts a single event at a specific sequence number.
@spec redact_for_event_source(t(), String.t(), String.t(), [module()], keyword()) :: :ok | {:error, term()}
Redacts all events for a given event source, optionally filtered to specific event types.
@spec transactional(t()) :: Chronicle.EventSequences.TransactionalEventSequence.t()
Gets a transactional view of the event sequence that buffers appends in the current unit of work.
@spec verify_content( t(), non_neg_integer(), struct() | Chronicle.EventSequences.PreparedEvent.t(), keyword() ) :: {:ok, :equal | :different | :unavailable} | {:error, term()}
Verifies that event is what was stored at sequence_number. See
Chronicle.EventSequences.Streams.verify_content/3.