Class ConcurrencyScope
- 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
originalConcurrencyScope
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
SequenceNumberEventSequenceNumberThe expected sequence number.
EventSourceIdEventSourceIdOptional EventSourceId to scope to. If not set, it will not be used.
EventStreamTypeEventStreamTypeOptional EventStreamType to scope to. If not set, it will not be used.
EventStreamIdEventStreamIdOptional EventStreamId to scope to. If not set, it will not be used.
EventSourceTypeEventSourceTypeOptional EventSourceType to scope to. If not set, it will not be used.
EventTypesIEnumerable<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
NotSet
Represents a concurrency scope that has not been specified yet.
public static readonly ConcurrencyScope NotSet
Field Value
Properties
EqualityContract
protected virtual Type EqualityContract { get; }
Property Value
EventSourceId
Optional EventSourceId to scope to. If not set, it will not be used.
public EventSourceId? EventSourceId { get; init; }
Property Value
EventSourceType
Optional EventSourceType to scope to. If not set, it will not be used.
public EventSourceType? EventSourceType { get; init; }
Property Value
EventStreamId
Optional EventStreamId to scope to. If not set, it will not be used.
public EventStreamId? EventStreamId { get; init; }
Property Value
EventStreamType
Optional EventStreamType to scope to. If not set, it will not be used.
public EventStreamType? EventStreamType { get; init; }
Property Value
EventTypes
Optional collection of EventType to scope to. If not set, it will not be used.
public IEnumerable<EventType>? EventTypes { get; init; }
Property Value
ExpectsNoMatchingEvent
Gets a value indicating whether the scope expects no event matching its narrowing to exist yet.
public bool ExpectsNoMatchingEvent { get; }
Property Value
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
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
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
SequenceNumberEventSequenceNumberEventSourceIdEventSourceIdEventStreamTypeEventStreamTypeEventStreamIdEventStreamIdEventSourceTypeEventSourceTypeEventTypesIEnumerable<EventType>
Equals(ConcurrencyScope?)
public virtual bool Equals(ConcurrencyScope? other)
Parameters
otherConcurrencyScope
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
GetHashCode()
public override int GetHashCode()
Returns
PrintMembers(StringBuilder)
protected virtual bool PrintMembers(StringBuilder builder)
Parameters
builderStringBuilder
Returns
ToString()
public override string ToString()
Returns
Operators
operator ==(ConcurrencyScope?, ConcurrencyScope?)
public static bool operator ==(ConcurrencyScope? left, ConcurrencyScope? right)
Parameters
leftConcurrencyScoperightConcurrencyScope
Returns
operator !=(ConcurrencyScope?, ConcurrencyScope?)
public static bool operator !=(ConcurrencyScope? left, ConcurrencyScope? right)
Parameters
leftConcurrencyScoperightConcurrencyScope