Represents a concurrency scope for Chronicle append operations.
Concurrency scopes let you assert the expected tail sequence number before appending one or more events. You can optionally narrow the check to the current event source, stream, source type, and event types.
alias Chronicle.Events.ConcurrencyScope
scope =
ConcurrencyScope.for_event_source(3,
event_types: [MyApp.Events.FundsDeposited, MyApp.Events.FundsWithdrawn]
)
:ok = Chronicle.append_many("account-42", [...], concurrency_scope: scope)The event_source_id option is a boolean because the actual event source id
comes from the Chronicle.append/3 or Chronicle.append_many/3 call.
Summary
Functions
Creates a concurrency scope that includes the current append event source id.
Creates a new concurrency scope.
Returns the sentinel scope representing no explicit concurrency constraint.
Types
@type event_type_module() :: module()
@type t() :: %Chronicle.Events.ConcurrencyScope{ event_source_id: boolean(), event_source_type: String.t(), event_stream_id: String.t(), event_stream_type: String.t(), event_types: [event_type_module()], sequence_number: non_neg_integer() }
Functions
@spec for_event_source(non_neg_integer(), [option()]) :: t()
Creates a concurrency scope that includes the current append event source id.
@spec new(non_neg_integer(), [option()]) :: t()
Creates a new concurrency scope.
@spec none() :: t()
Returns the sentinel scope representing no explicit concurrency constraint.