Class ConcurrencyScopeBuilder

Namespace
Cratis.Chronicle.EventSequences.Concurrency
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

stream string

Optional name of a stream declared by the event source.

streamId EventStreamId

Optional EventStreamId within the stream.

Returns

ConcurrencyScopeBuilder

ConcurrencyScopeBuilder for continuation.

Type Parameters

TSource

The 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

eventSourceId EventSourceId

EventSourceId to scope to.

Returns

ConcurrencyScopeBuilder

ConcurrencyScopeBuilder for continuation.

WithEventSourceType(EventSourceType)

Sets the EventSourceType for the concurrency scope.

public ConcurrencyScopeBuilder WithEventSourceType(EventSourceType eventSourceType)

Parameters

eventSourceType EventSourceType

EventSourceType to scope to.

Returns

ConcurrencyScopeBuilder

ConcurrencyScopeBuilder for continuation.

WithEventStreamId(EventStreamId)

Sets the EventStreamId for the concurrency scope.

public ConcurrencyScopeBuilder WithEventStreamId(EventStreamId eventStreamId)

Parameters

eventStreamId EventStreamId

EventStreamId to scope to.

Returns

ConcurrencyScopeBuilder

ConcurrencyScopeBuilder for continuation.

WithEventStreamType(EventStreamType)

Sets the EventStreamType for the concurrency scope.

public ConcurrencyScopeBuilder WithEventStreamType(EventStreamType eventStreamType)

Parameters

eventStreamType EventStreamType

EventStreamType to scope to.

Returns

ConcurrencyScopeBuilder

ConcurrencyScopeBuilder for continuation.

WithEventType(EventType)

Adds a EventType for the concurrency scope.

public ConcurrencyScopeBuilder WithEventType(EventType eventType)

Parameters

eventType EventType

EventType to scope to.

Returns

ConcurrencyScopeBuilder

ConcurrencyScopeBuilder for continuation.

WithEventType(Type)

Adds a EventType for the concurrency scope.

public ConcurrencyScopeBuilder WithEventType(Type type)

Parameters

type Type

Type 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

T

Type 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

eventTypes IEnumerable<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

sequenceNumber EventSequenceNumber

EventSequenceNumber to scope to.

Returns

ConcurrencyScopeBuilder

ConcurrencyScopeBuilder for continuation.