Class ConcurrencyScope

Namespace
Cratis.Chronicle.EventSequences.Concurrency
Assembly
Cratis.Chronicle.dll

Represents a concurrency scope for an event sequence append operation.

public record ConcurrencyScope : IEquatable<ConcurrencyScope>
Inheritance
ConcurrencyScope
Implements
Inherited Members
Extension Methods

Constructors

ConcurrencyScope(ConcurrencyScope)

protected ConcurrencyScope(ConcurrencyScope original)

Parameters

original ConcurrencyScope

ConcurrencyScope(EventSequenceNumber, EventSourceId?, EventStreamType?, EventStreamId?, EventSourceType?, IEnumerable<EventType>?)

Represents a concurrency scope for an event sequence append operation.

public ConcurrencyScope(EventSequenceNumber SequenceNumber, EventSourceId? EventSourceId = null, EventStreamType? EventStreamType = null, EventStreamId? EventStreamId = null, EventSourceType? EventSourceType = null, IEnumerable<EventType>? EventTypes = null)

Parameters

SequenceNumber EventSequenceNumber

The expected sequence number.

EventSourceId EventSourceId

Optional EventSourceId to scope to. If not set, it will not be used.

EventStreamType EventStreamType

Optional EventStreamType to scope to. If not set, it will not be used.

EventStreamId EventStreamId

Optional EventStreamId to scope to. If not set, it will not be used.

EventSourceType EventSourceType

Optional EventSourceType to scope to. If not set, it will not be used.

EventTypes IEnumerable<EventType>

Optional collection of EventType to scope to. If not set, it will not be used.

Fields

None

Represents a concurrency scope that does not apply any constraints.

public static readonly ConcurrencyScope None

Field Value

ConcurrencyScope

NotSet

Represents a concurrency scope that has not been specified yet.

public static readonly ConcurrencyScope NotSet

Field Value

ConcurrencyScope

Properties

EqualityContract

protected virtual Type EqualityContract { get; }

Property Value

Type

EventSourceId

Optional EventSourceId to scope to. If not set, it will not be used.

public EventSourceId? EventSourceId { get; init; }

Property Value

EventSourceId

EventSourceType

Optional EventSourceType to scope to. If not set, it will not be used.

public EventSourceType? EventSourceType { get; init; }

Property Value

EventSourceType

EventStreamId

Optional EventStreamId to scope to. If not set, it will not be used.

public EventStreamId? EventStreamId { get; init; }

Property Value

EventStreamId

EventStreamType

Optional EventStreamType to scope to. If not set, it will not be used.

public EventStreamType? EventStreamType { get; init; }

Property Value

EventStreamType

EventTypes

Optional collection of EventType to scope to. If not set, it will not be used.

public IEnumerable<EventType>? EventTypes { get; init; }

Property Value

IEnumerable<EventType>

ExpectsNoMatchingEvent

Gets a value indicating whether the scope expects no event matching its narrowing to exist yet.

public bool ExpectsNoMatchingEvent { get; }

Property Value

bool

Remarks

This is what OptimisticConcurrencyStrategy produces for the first append into a scope: it reads the tail through the scope's own narrowing and finds no event matching it, so it answers BeforeFirst rather than a number. The kernel validates it as "no event matching this scope may exist" and rejects the append if one appeared in the meantime.

IsIncomplete

Gets a value indicating whether the scope narrows an append without saying which sequence number it expects.

public bool IsIncomplete { get; }

Property Value

bool

Remarks

It is not NotSet, so the configured IConcurrencyScopeStrategy does not get to supply the expected sequence number, and it has no sequence number of its own for the kernel to validate against - so the append is checked against nothing, which looks exactly like never having asked for a check. Build None to append without a check, or NotSet to let the strategy resolve the expected sequence number. A scope OptimisticConcurrencyStrategy resolved lands here too, for the first append into a scope, unless CheckFirstAppendIntoAScope is turned on - with it on, an empty narrowing gives ExpectsNoMatchingEvent, which the kernel checks.

SequenceNumber

The expected sequence number.

public EventSequenceNumber SequenceNumber { get; init; }

Property Value

EventSequenceNumber

Methods

Deconstruct(out EventSequenceNumber, out EventSourceId?, out EventStreamType?, out EventStreamId?, out EventSourceType?, out IEnumerable<EventType>?)

public void Deconstruct(out EventSequenceNumber SequenceNumber, out EventSourceId? EventSourceId, out EventStreamType? EventStreamType, out EventStreamId? EventStreamId, out EventSourceType? EventSourceType, out IEnumerable<EventType>? EventTypes)

Parameters

SequenceNumber EventSequenceNumber
EventSourceId EventSourceId
EventStreamType EventStreamType
EventStreamId EventStreamId
EventSourceType EventSourceType
EventTypes IEnumerable<EventType>

Equals(ConcurrencyScope?)

public virtual bool Equals(ConcurrencyScope? other)

Parameters

other ConcurrencyScope

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

GetHashCode()

public override int GetHashCode()

Returns

int

PrintMembers(StringBuilder)

protected virtual bool PrintMembers(StringBuilder builder)

Parameters

builder StringBuilder

Returns

bool

ToString()

public override string ToString()

Returns

string

Operators

operator ==(ConcurrencyScope?, ConcurrencyScope?)

public static bool operator ==(ConcurrencyScope? left, ConcurrencyScope? right)

Parameters

left ConcurrencyScope
right ConcurrencyScope

Returns

bool

operator !=(ConcurrencyScope?, ConcurrencyScope?)

public static bool operator !=(ConcurrencyScope? left, ConcurrencyScope? right)

Parameters

left ConcurrencyScope
right ConcurrencyScope

Returns

bool