Class ConcurrencyScopeBuilder
- Assembly
- Cratis.Chronicle.dll
Builder for creating a ConcurrencyScope for an event sequence append operation.
public class ConcurrencyScopeBuilder
- Inheritance
-
ConcurrencyScopeBuilder
- Inherited Members
- Extension Methods
Constructors
ConcurrencyScopeBuilder()
public ConcurrencyScopeBuilder()
Methods
Build()
Builds the ConcurrencyScope with the configured properties.
public ConcurrencyScope Build()
Returns
- ConcurrencyScope
A new instance of ConcurrencyScope.
ExpectingNoMatchingEvent()
Expect no event matching this scope's narrowing to exist yet.
public ConcurrencyScopeBuilder ExpectingNoMatchingEvent()
Returns
- ConcurrencyScopeBuilder
ConcurrencyScopeBuilder for continuation.
Remarks
The expectation a first append actually has. The kernel rejects the append with a concurrency violation if an event matching the narrowing appeared between the scope being built and the append arriving, which is how "only one writer may open this partition" is expressed as a concurrency concern. This asks for the check on one append. To have OptimisticConcurrencyStrategy produce it for every first append, turn on CheckFirstAppendIntoAScope instead.
ForEventSource<TSource>(string?, EventStreamId?)
Scopes the check to an event source and optionally one of its streams.
public ConcurrencyScopeBuilder ForEventSource<TSource>(string? stream = null, EventStreamId? streamId = null) where TSource : IEventSource
Parameters
streamstringOptional name of a stream declared by the event source.
streamIdEventStreamIdOptional EventStreamId within the stream.
Returns
- ConcurrencyScopeBuilder
ConcurrencyScopeBuilder for continuation.
Type Parameters
TSourceThe IEventSource to scope to.
Exceptions
- EventStreamDoesNotBelongToEventSource
The stream is not declared by the event source.
WithEventSourceId(EventSourceId)
Sets the EventSourceId for the concurrency scope.
public ConcurrencyScopeBuilder WithEventSourceId(EventSourceId eventSourceId)
Parameters
eventSourceIdEventSourceIdEventSourceId to scope to.
Returns
- ConcurrencyScopeBuilder
ConcurrencyScopeBuilder for continuation.
WithEventSourceType(EventSourceType)
Sets the EventSourceType for the concurrency scope.
public ConcurrencyScopeBuilder WithEventSourceType(EventSourceType eventSourceType)
Parameters
eventSourceTypeEventSourceTypeEventSourceType to scope to.
Returns
- ConcurrencyScopeBuilder
ConcurrencyScopeBuilder for continuation.
WithEventStreamId(EventStreamId)
Sets the EventStreamId for the concurrency scope.
public ConcurrencyScopeBuilder WithEventStreamId(EventStreamId eventStreamId)
Parameters
eventStreamIdEventStreamIdEventStreamId to scope to.
Returns
- ConcurrencyScopeBuilder
ConcurrencyScopeBuilder for continuation.
WithEventStreamType(EventStreamType)
Sets the EventStreamType for the concurrency scope.
public ConcurrencyScopeBuilder WithEventStreamType(EventStreamType eventStreamType)
Parameters
eventStreamTypeEventStreamTypeEventStreamType to scope to.
Returns
- ConcurrencyScopeBuilder
ConcurrencyScopeBuilder for continuation.
WithEventType(EventType)
Adds a EventType for the concurrency scope.
public ConcurrencyScopeBuilder WithEventType(EventType eventType)
Parameters
Returns
- ConcurrencyScopeBuilder
ConcurrencyScopeBuilder for continuation.
WithEventType(Type)
Adds a EventType for the concurrency scope.
public ConcurrencyScopeBuilder WithEventType(Type type)
Parameters
typeTypeType of the event to scope to.
Returns
- ConcurrencyScopeBuilder
ConcurrencyScopeBuilder for continuation.
WithEventType<T>()
Adds a EventType for the concurrency scope.
public ConcurrencyScopeBuilder WithEventType<T>()
Returns
- ConcurrencyScopeBuilder
ConcurrencyScopeBuilder for continuation.
Type Parameters
TType of the event to scope to.
WithEventTypes(IEnumerable<EventType>)
Adds a collection of EventTypes for the concurrency scope.
public ConcurrencyScopeBuilder WithEventTypes(IEnumerable<EventType> eventTypes)
Parameters
eventTypesIEnumerable<EventType>Collection of EventTypes to scope to.
Returns
- ConcurrencyScopeBuilder
ConcurrencyScopeBuilder for continuation.
WithSequenceNumber(EventSequenceNumber)
Sets the EventSequenceNumber for the concurrency scope.
public ConcurrencyScopeBuilder WithSequenceNumber(EventSequenceNumber sequenceNumber)
Parameters
sequenceNumberEventSequenceNumberEventSequenceNumber to scope to.
Returns
- ConcurrencyScopeBuilder
ConcurrencyScopeBuilder for continuation.