Class EventSequence
- Namespace
- Cratis.Chronicle.EventSequences
- Assembly
- Cratis.Chronicle.dll
Represents an implementation of IEventSequence for gRPC.
public class EventSequence : IEventSequence
- Inheritance
-
EventSequence
- Implements
- Derived
- Inherited Members
- Extension Methods
Remarks
Initializes a new instance of the EventSequence class.
Constructors
EventSequence(EventStoreName, EventStoreNamespaceName, EventSequenceId, IChronicleConnection, IEventTypes, IConstraints, IEventSerializer, ICorrelationIdAccessor, IConcurrencyScopeStrategies, ICausationManager, IUnitOfWorkManager, IIdentityProvider, JsonSerializerOptions, IActivitySource<EventSequence>?, IReactorSideEffectHandlers?, IEventSources?)
Represents an implementation of IEventSequence for gRPC.
public EventSequence(EventStoreName eventStoreName, EventStoreNamespaceName @namespace, EventSequenceId eventSequenceId, IChronicleConnection connection, IEventTypes eventTypes, IConstraints constraints, IEventSerializer eventSerializer, ICorrelationIdAccessor correlationIdAccessor, IConcurrencyScopeStrategies concurrencyScopeStrategies, ICausationManager causationManager, IUnitOfWorkManager unitOfWorkManager, IIdentityProvider identityProvider, JsonSerializerOptions jsonSerializerOptions, IActivitySource<EventSequence>? activitySource = null, IReactorSideEffectHandlers? sideEffectHandlers = null, IEventSources? eventSources = null)
Parameters
eventStoreNameEventStoreNameName of the event store.
namespaceEventStoreNamespaceNameNamespace for the event store.
eventSequenceIdEventSequenceIdThe identifier of the event sequence.
connectionIChronicleConnectionIChronicleConnection for working with the connection to Chronicle.
eventTypesIEventTypesKnown IEventTypes.
constraintsIConstraintsKnown IConstraints.
eventSerializerIEventSerializerThe IEventSerializer for serializing events.
correlationIdAccessorICorrelationIdAccessorICorrelationIdAccessor for getting correlation.
concurrencyScopeStrategiesIConcurrencyScopeStrategiesIConcurrencyScopeStrategies for managing concurrency scopes.
causationManagerICausationManagerICausationManager for getting causation.
unitOfWorkManagerIUnitOfWorkManagerIUnitOfWorkManager for working with the unit of work.
identityProviderIIdentityProviderIIdentityProvider for resolving identity for operations.
jsonSerializerOptionsJsonSerializerOptionsJSON serializer options to use.
activitySourceIActivitySource<EventSequence>Optional IActivitySource<T> for tracing. Defaults to a source named SourceName when not provided.
sideEffectHandlersIReactorSideEffectHandlersOptional handlers used to recognize synchronous reactor return types.
eventSourcesIEventSourcesOptional IEventSources for appending through event source definitions.
Remarks
Initializes a new instance of the EventSequence class.
Properties
AppendOperations
Gets an observable that emits a collection of AppendedEventWithResult after each append operation.
public IObservable<IEnumerable<AppendedEventWithResult>> AppendOperations { get; }
Property Value
Remarks
Both single-event and batch append operations emit through this observable. A single-event append emits a collection of one element; a batch append emits the full batch. Subscribers receive the notification after the operation has completed, whether it succeeded or failed. This observable does not fire for transactional appends through ITransactionalEventSequence.
Id
Gets the EventSequenceId for the event sequence.
public EventSequenceId Id { get; }
Property Value
SupportsIdempotentAppends
Gets a value indicating whether this implementation can append with an IdempotencyKey. Defaults to false.
public bool SupportsIdempotentAppends { get; }
Property Value
Remarks
Check this before choosing keyed appends when an older kernel may be connected; a keyed append never falls back to an unkeyed one.
Transactional
Gets the transactional event sequence.
public ITransactionalEventSequence Transactional { get; }
Property Value
Remarks
Use this when you want to typically append events to the event sequence as a transaction that takes place in the same unit of work. This is very useful when you have disperse event sources that you want to append events to in a single transaction, typically within one request. Using this will also mean that any result will be handled by Chronicle infrastructure and bubbled up, typically when using Chronicle with ASP.NET Core.
Methods
Append(EventSourceId, object, EventStreamType?, EventStreamId?, EventSourceType?, CorrelationId?, IEnumerable<string>?, ConcurrencyScope?, DateTimeOffset?, Subject?)
Append a single event to the event store.
public Task<AppendResult> Append(EventSourceId eventSourceId, object @event, EventStreamType? eventStreamType = null, EventStreamId? eventStreamId = null, EventSourceType? eventSourceType = null, CorrelationId? correlationId = null, IEnumerable<string>? tags = null, ConcurrencyScope? concurrencyScope = null, DateTimeOffset? occurred = null, Subject? subject = null)
Parameters
eventSourceIdEventSourceIdThe EventSourceId to append for.
eventobjectThe event.
eventStreamTypeEventStreamTypeOptional EventStreamType to append to. Defaults to All.
eventStreamIdEventStreamIdOptional EventStreamId to append to. Defaults to Default.
eventSourceTypeEventSourceTypeOptional EventSourceType to append to. Defaults to Default.
correlationIdCorrelationIdOptional CorrelationId of the event. Defaults to Current.
tagsIEnumerable<string>Optional collection of tags to associate with the event. Will be combined with any static tags from the event type.
concurrencyScopeConcurrencyScopeOptional ConcurrencyScope to use for concurrency control. Defaults to None.
occurredDateTimeOffset?Optional DateTimeOffset specifying when the event occurred. If not set, the server will set it to approximately the time of append.
subjectSubjectOptional Subject identifying the target the event is about. Used as the identity for compliance concerns such as PII encryption keys. When omitted, the
eventSourceIdis used as the subject.
Returns
- Task<AppendResult>
AppendResult with details about whether or not it succeeded and more.
AppendMany(EventSourceId, IEnumerable<object>, EventStreamType?, EventStreamId?, EventSourceType?, CorrelationId?, IEnumerable<string>?, ConcurrencyScope?, DateTimeOffset?, Subject?)
Append a collection of events to the event store as a transaction.
public Task<AppendManyResult> AppendMany(EventSourceId eventSourceId, IEnumerable<object> events, EventStreamType? eventStreamType = null, EventStreamId? eventStreamId = null, EventSourceType? eventSourceType = null, CorrelationId? correlationId = null, IEnumerable<string>? tags = null, ConcurrencyScope? concurrencyScope = null, DateTimeOffset? occurred = null, Subject? subject = null)
Parameters
eventSourceIdEventSourceIdThe EventSourceId to append for.
eventsIEnumerable<object>Collection of events to append.
eventStreamTypeEventStreamTypeOptional EventStreamType to append to. Defaults to All.
eventStreamIdEventStreamIdOptional EventStreamId to append to. Defaults to Default.
eventSourceTypeEventSourceTypeOptional EventSourceType to append to. Defaults to Default.
correlationIdCorrelationIdOptional CorrelationId of the event. Defaults to Current.
tagsIEnumerable<string>Optional collection of tags to associate with all events. Will be combined with any static tags from the event types.
concurrencyScopeConcurrencyScopeOptional ConcurrencyScope to use for concurrency control. Defaults to None.
occurredDateTimeOffset?Optional DateTimeOffset specifying when the events occurred. If not set, the server will set it to approximately the time of append.
subjectSubjectOptional Subject identifying the target the events are about. Used as the identity for compliance concerns such as PII encryption keys.
Returns
- Task<AppendManyResult>
AppendManyResult with details about whether or not it succeeded and more.
Remarks
All events will be committed as one operation for the underlying data store.
AppendMany(IEnumerable<EventForEventSourceId>, CorrelationId?, IEnumerable<string>?, IDictionary<EventSourceId, ConcurrencyScope>?)
Append a collection of events to the event store as a transaction.
public Task<AppendManyResult> AppendMany(IEnumerable<EventForEventSourceId> events, CorrelationId? correlationId = null, IEnumerable<string>? tags = null, IDictionary<EventSourceId, ConcurrencyScope>? concurrencyScopes = null)
Parameters
eventsIEnumerable<EventForEventSourceId>Collection of EventForEventSourceId to append.
correlationIdCorrelationIdOptional CorrelationId of the event. Defaults to Current.
tagsIEnumerable<string>Optional collection of tags to associate with all events. Will be combined with any static tags from the event types.
concurrencyScopesIDictionary<EventSourceId, ConcurrencyScope>Optional IDictionary<TKey, TValue> of EventSourceId and ConcurrencyScope to use for concurrency control. Defaults to an empty dictionary.
Returns
- Task<AppendManyResult>
AppendManyResult with details about whether or not it succeeded and more.
Remarks
All events will be committed as one operation for the underlying data store. When any event carries an IdempotencyKey the batch is appended once. Third-party implementations that override this method themselves drop those keys; check SupportsIdempotentAppends first.
AppendMany(IEnumerable<EventForEventSourceId>, CorrelationId?, IEnumerable<string>?, IEnumerable<KeyValuePair<EventSourceId, ConcurrencyScope>>)
Appends a batch atomically, requiring every supplied concurrency predicate to hold.
public Task<AppendManyResult> AppendMany(IEnumerable<EventForEventSourceId> events, CorrelationId? correlationId, IEnumerable<string>? tags, IEnumerable<KeyValuePair<EventSourceId, ConcurrencyScope>> concurrencyScopes)
Parameters
eventsIEnumerable<EventForEventSourceId>The events in append order.
correlationIdCorrelationIdOptional correlation id.
tagsIEnumerable<string>Optional shared tags.
concurrencyScopesIEnumerable<KeyValuePair<EventSourceId, ConcurrencyScope>>Ordered guards; labels may repeat for different predicates.
Returns
- Task<AppendManyResult>
The atomic batch result.
AppendManyOnce(EventSourceId, IEnumerable<object>, IdempotencyKey, EventStreamType?, EventStreamId?, EventSourceType?, CorrelationId?, IEnumerable<string>?, ConcurrencyScope?, DateTimeOffset?, Subject?)
Append events for one source once. The key is expanded per event with ForIndex(int).
public Task<AppendManyResult> AppendManyOnce(EventSourceId eventSourceId, IEnumerable<object> events, IdempotencyKey idempotencyKey, EventStreamType? eventStreamType = null, EventStreamId? eventStreamId = null, EventSourceType? eventSourceType = null, CorrelationId? correlationId = null, IEnumerable<string>? tags = null, ConcurrencyScope? concurrencyScope = null, DateTimeOffset? occurred = null, Subject? subject = null)
Parameters
eventSourceIdEventSourceIdThe event source.
eventsIEnumerable<object>The events.
idempotencyKeyIdempotencyKeyThe key identifying this batch.
eventStreamTypeEventStreamTypeOptional stream type.
eventStreamIdEventStreamIdOptional stream id.
eventSourceTypeEventSourceTypeOptional source type.
correlationIdCorrelationIdOptional correlation id.
tagsIEnumerable<string>Optional plain tags.
concurrencyScopeConcurrencyScopeOptional concurrency scope.
occurredDateTimeOffset?Optional occurred time.
subjectSubjectOptional subject.
Returns
- Task<AppendManyResult>
The batch result, carrying an Outcomes entry per event.
Exceptions
- IdempotentAppendsNotSupported
The kernel or this implementation cannot honor the key; nothing was sent.
AppendManyOnceWithNamedTags(EventSourceId, IEnumerable<object>, IdempotencyKey, IEnumerable<NamedTag>, EventStreamType?, EventStreamId?, EventSourceType?, CorrelationId?, IEnumerable<string>?, ConcurrencyScope?, DateTimeOffset?, Subject?)
Append events for one source once, with structured named tags for every event.
public Task<AppendManyResult> AppendManyOnceWithNamedTags(EventSourceId eventSourceId, IEnumerable<object> events, IdempotencyKey idempotencyKey, IEnumerable<NamedTag> namedTags, EventStreamType? eventStreamType = null, EventStreamId? eventStreamId = null, EventSourceType? eventSourceType = null, CorrelationId? correlationId = null, IEnumerable<string>? tags = null, ConcurrencyScope? concurrencyScope = null, DateTimeOffset? occurred = null, Subject? subject = null)
Parameters
eventSourceIdEventSourceIdThe event source.
eventsIEnumerable<object>The events.
idempotencyKeyIdempotencyKeyThe key identifying this batch.
namedTagsIEnumerable<NamedTag>Structured named tags for every event.
eventStreamTypeEventStreamTypeOptional stream type.
eventStreamIdEventStreamIdOptional stream id.
eventSourceTypeEventSourceTypeOptional source type.
correlationIdCorrelationIdOptional correlation id.
tagsIEnumerable<string>Optional plain tags.
concurrencyScopeConcurrencyScopeOptional concurrency scope.
occurredDateTimeOffset?Optional occurred time.
subjectSubjectOptional subject.
Returns
- Task<AppendManyResult>
The batch result, carrying an Outcomes entry per event.
Exceptions
- NamedTagsNotSupported
The implementation cannot append nonempty named tags.
- IdempotentAppendsNotSupported
The kernel or this implementation cannot honor the key; nothing was sent.
AppendManyThroughEventSource(Type, EventSourceId, IEnumerable<object>, string?, EventStreamId?, CorrelationId?, IEnumerable<string>?, ConcurrencyScope?, DateTimeOffset?, Subject?)
Appends several events through a registered event source definition.
public Task<AppendManyResult> AppendManyThroughEventSource(Type eventSource, EventSourceId eventSourceId, IEnumerable<object> events, string? eventStream = null, EventStreamId? eventStreamId = null, CorrelationId? correlationId = null, IEnumerable<string>? tags = null, ConcurrencyScope? concurrencyScope = null, DateTimeOffset? occurred = null, Subject? subject = null)
Parameters
eventSourceTypeThe type of the IEventSource to append through.
eventSourceIdEventSourceIdThe EventSourceId of the event source instance.
eventsIEnumerable<object>The events to append.
eventStreamstringOptional name of a stream declared by the event source.
eventStreamIdEventStreamIdOptional EventStreamId within the stream. The format is left to the caller.
correlationIdCorrelationIdOptional CorrelationId of the events.
tagsIEnumerable<string>Optional tags to associate with the events.
concurrencyScopeConcurrencyScopeOptional ConcurrencyScope. When not set it is narrowed to the dimensions the definition declares.
occurredDateTimeOffset?Optional time the events occurred.
subjectSubjectOptional Subject of the events.
Returns
- Task<AppendManyResult>
AppendManyResult with details about whether or not it succeeded and more.
Exceptions
- UnknownEventSource
The type is not a discovered event source.
- EventStreamDoesNotBelongToEventSource
The stream is not declared by the event source.
- EventSourcesNotSupported
The implementation does not support event sources.
AppendManyWithNamedTags(EventSourceId, IEnumerable<object>, IEnumerable<NamedTag>, EventStreamType?, EventStreamId?, EventSourceType?, CorrelationId?, IEnumerable<string>?, ConcurrencyScope?, DateTimeOffset?, Subject?)
Append events for one source with structured named tags.
public Task<AppendManyResult> AppendManyWithNamedTags(EventSourceId eventSourceId, IEnumerable<object> events, IEnumerable<NamedTag> namedTags, EventStreamType? eventStreamType = null, EventStreamId? eventStreamId = null, EventSourceType? eventSourceType = null, CorrelationId? correlationId = null, IEnumerable<string>? tags = null, ConcurrencyScope? concurrencyScope = null, DateTimeOffset? occurred = null, Subject? subject = null)
Parameters
eventSourceIdEventSourceIdThe event source.
eventsIEnumerable<object>The events.
namedTagsIEnumerable<NamedTag>Structured named tags for every event.
eventStreamTypeEventStreamTypeOptional stream type.
eventStreamIdEventStreamIdOptional stream id.
eventSourceTypeEventSourceTypeOptional source type.
correlationIdCorrelationIdOptional correlation id.
tagsIEnumerable<string>Optional plain tags.
concurrencyScopeConcurrencyScopeOptional concurrency scope.
occurredDateTimeOffset?Optional occurred time.
subjectSubjectOptional subject.
Returns
- Task<AppendManyResult>
The batch result.
Exceptions
- NamedTagsNotSupported
The implementation cannot append nonempty named tags.
AppendManyWithNamedTags(IEnumerable<EventForEventSourceId>, IEnumerable<NamedTag>, CorrelationId?, IEnumerable<string>?, IDictionary<EventSourceId, ConcurrencyScope>?)
Append events for several sources with structured named tags.
public Task<AppendManyResult> AppendManyWithNamedTags(IEnumerable<EventForEventSourceId> events, IEnumerable<NamedTag> namedTags, CorrelationId? correlationId = null, IEnumerable<string>? tags = null, IDictionary<EventSourceId, ConcurrencyScope>? concurrencyScopes = null)
Parameters
eventsIEnumerable<EventForEventSourceId>The events, including their own named tags.
namedTagsIEnumerable<NamedTag>Structured named tags shared by all events.
correlationIdCorrelationIdOptional correlation id.
tagsIEnumerable<string>Optional plain tags.
concurrencyScopesIDictionary<EventSourceId, ConcurrencyScope>Optional concurrency scopes.
Returns
- Task<AppendManyResult>
The batch result.
Exceptions
- NamedTagsNotSupported
The implementation cannot append nonempty named tags.
AppendManyWithNamedTags(IEnumerable<EventForEventSourceId>, IEnumerable<NamedTag>, CorrelationId?, IEnumerable<string>?, IEnumerable<KeyValuePair<EventSourceId, ConcurrencyScope>>)
Appends a batch with named tags and an ordered conjunction of guards.
public Task<AppendManyResult> AppendManyWithNamedTags(IEnumerable<EventForEventSourceId> events, IEnumerable<NamedTag> namedTags, CorrelationId? correlationId, IEnumerable<string>? tags, IEnumerable<KeyValuePair<EventSourceId, ConcurrencyScope>> concurrencyScopes)
Parameters
eventsIEnumerable<EventForEventSourceId>The events in append order.
namedTagsIEnumerable<NamedTag>Shared named tags.
correlationIdCorrelationIdOptional correlation id.
tagsIEnumerable<string>Optional shared tags.
concurrencyScopesIEnumerable<KeyValuePair<EventSourceId, ConcurrencyScope>>Ordered guards; labels may repeat for different predicates.
Returns
- Task<AppendManyResult>
The atomic batch result.
AppendOnce(EventSourceId, object, IdempotencyKey, EventStreamType?, EventStreamId?, EventSourceType?, CorrelationId?, IEnumerable<string>?, ConcurrencyScope?, DateTimeOffset?, Subject?)
Append a single event once: appending again with the same idempotencyKey writes nothing and reports AlreadyAppended.
public Task<AppendResult> AppendOnce(EventSourceId eventSourceId, object @event, IdempotencyKey idempotencyKey, EventStreamType? eventStreamType = null, EventStreamId? eventStreamId = null, EventSourceType? eventSourceType = null, CorrelationId? correlationId = null, IEnumerable<string>? tags = null, ConcurrencyScope? concurrencyScope = null, DateTimeOffset? occurred = null, Subject? subject = null)
Parameters
eventSourceIdEventSourceIdThe event source.
eventobjectThe event.
idempotencyKeyIdempotencyKeyThe key identifying this append.
eventStreamTypeEventStreamTypeOptional stream type.
eventStreamIdEventStreamIdOptional stream id.
eventSourceTypeEventSourceTypeOptional source type.
correlationIdCorrelationIdOptional correlation id.
tagsIEnumerable<string>Optional plain tags.
concurrencyScopeConcurrencyScopeOptional concurrency scope.
occurredDateTimeOffset?Optional occurred time.
subjectSubjectOptional subject.
Returns
- Task<AppendResult>
The append result, carrying the Outcome.
Exceptions
- IdempotentAppendsNotSupported
The kernel or this implementation cannot honor the key; nothing was sent.
AppendOnceWithNamedTags(EventSourceId, object, IdempotencyKey, IEnumerable<NamedTag>, EventStreamType?, EventStreamId?, EventSourceType?, CorrelationId?, IEnumerable<string>?, ConcurrencyScope?, DateTimeOffset?, Subject?)
Append a single event once, with structured named tags.
public Task<AppendResult> AppendOnceWithNamedTags(EventSourceId eventSourceId, object @event, IdempotencyKey idempotencyKey, IEnumerable<NamedTag> namedTags, EventStreamType? eventStreamType = null, EventStreamId? eventStreamId = null, EventSourceType? eventSourceType = null, CorrelationId? correlationId = null, IEnumerable<string>? tags = null, ConcurrencyScope? concurrencyScope = null, DateTimeOffset? occurred = null, Subject? subject = null)
Parameters
eventSourceIdEventSourceIdThe event source.
eventobjectThe event.
idempotencyKeyIdempotencyKeyThe key identifying this append.
namedTagsIEnumerable<NamedTag>Structured named tags for the event.
eventStreamTypeEventStreamTypeOptional stream type.
eventStreamIdEventStreamIdOptional stream id.
eventSourceTypeEventSourceTypeOptional source type.
correlationIdCorrelationIdOptional correlation id.
tagsIEnumerable<string>Optional plain tags.
concurrencyScopeConcurrencyScopeOptional concurrency scope.
occurredDateTimeOffset?Optional occurred time.
subjectSubjectOptional subject.
Returns
- Task<AppendResult>
The append result, carrying the Outcome.
Exceptions
- NamedTagsNotSupported
The implementation cannot append nonempty named tags.
- IdempotentAppendsNotSupported
The kernel or this implementation cannot honor the key; nothing was sent.
AppendPrepared(EventSourceId, PreparedEvent, EventStreamType?, EventStreamId?, EventSourceType?, CorrelationId?, IEnumerable<string>?, ConcurrencyScope?, DateTimeOffset?, Subject?)
Appends prepared content without serializing the event or running providers again.
public Task<AppendResult> AppendPrepared(EventSourceId eventSourceId, PreparedEvent preparedEvent, EventStreamType? eventStreamType = null, EventStreamId? eventStreamId = null, EventSourceType? eventSourceType = null, CorrelationId? correlationId = null, IEnumerable<string>? tags = null, ConcurrencyScope? concurrencyScope = null, DateTimeOffset? occurred = null, Subject? subject = null)
Parameters
eventSourceIdEventSourceIdThe event source.
preparedEventPreparedEventThe content prepared by this sequence.
eventStreamTypeEventStreamTypeOptional stream type.
eventStreamIdEventStreamIdOptional stream id.
eventSourceTypeEventSourceTypeOptional source type.
correlationIdCorrelationIdOptional correlation id.
tagsIEnumerable<string>Optional tags.
concurrencyScopeConcurrencyScopeOptional concurrency scope.
occurredDateTimeOffset?Optional occurrence time.
subjectSubjectOptional subject overriding the prepared event's subject.
Returns
- Task<AppendResult>
The append outcome.
Exceptions
- PreparedEventsNotSupported
This implementation does not support prepared appends.
- PreparedEventBelongsToAnotherSequence
The content belongs to another sequence instance.
AppendPreparedThroughEventSource(Type, EventSourceId, PreparedEvent, string?, EventStreamId?, CorrelationId?, IEnumerable<string>?, ConcurrencyScope?, DateTimeOffset?, Subject?)
Appends prepared content through a registered event source definition without serializing the event or running providers again.
public Task<AppendResult> AppendPreparedThroughEventSource(Type eventSource, EventSourceId eventSourceId, PreparedEvent preparedEvent, string? eventStream = null, EventStreamId? eventStreamId = null, CorrelationId? correlationId = null, IEnumerable<string>? tags = null, ConcurrencyScope? concurrencyScope = null, DateTimeOffset? occurred = null, Subject? subject = null)
Parameters
eventSourceTypeThe type of the IEventSource to append through.
eventSourceIdEventSourceIdThe EventSourceId of the event source instance.
preparedEventPreparedEventThe content prepared by this sequence.
eventStreamstringOptional name of a stream declared by the event source.
eventStreamIdEventStreamIdOptional EventStreamId within the stream. The format is left to the caller.
correlationIdCorrelationIdOptional CorrelationId of the event.
tagsIEnumerable<string>Optional tags to associate with the event.
concurrencyScopeConcurrencyScopeOptional ConcurrencyScope. When not set it is narrowed to the dimensions the definition declares.
occurredDateTimeOffset?Optional time the event occurred.
subjectSubjectOptional subject overriding the prepared event's subject.
Returns
- Task<AppendResult>
The append outcome.
Exceptions
- UnknownEventSource
The type is not a discovered event source.
- EventStreamDoesNotBelongToEventSource
The stream is not declared by the event source.
- PreparedEventsNotSupported
This implementation does not support prepared appends.
- PreparedEventBelongsToAnotherSequence
The content belongs to another sequence instance.
AppendThroughEventSource(Type, EventSourceId, object, string?, EventStreamId?, CorrelationId?, IEnumerable<string>?, ConcurrencyScope?, DateTimeOffset?, Subject?)
Appends an event through a registered event source definition.
public Task<AppendResult> AppendThroughEventSource(Type eventSource, EventSourceId eventSourceId, object @event, string? eventStream = null, EventStreamId? eventStreamId = null, CorrelationId? correlationId = null, IEnumerable<string>? tags = null, ConcurrencyScope? concurrencyScope = null, DateTimeOffset? occurred = null, Subject? subject = null)
Parameters
eventSourceTypeThe type of the IEventSource to append through.
eventSourceIdEventSourceIdThe EventSourceId of the event source instance.
eventobjectThe event to append.
eventStreamstringOptional name of a stream declared by the event source.
eventStreamIdEventStreamIdOptional EventStreamId within the stream. The format is left to the caller.
correlationIdCorrelationIdOptional CorrelationId of the event.
tagsIEnumerable<string>Optional tags to associate with the event.
concurrencyScopeConcurrencyScopeOptional ConcurrencyScope. When not set it is narrowed to the dimensions the definition declares.
occurredDateTimeOffset?Optional time the event occurred.
subjectSubjectOptional Subject of the event.
Returns
- Task<AppendResult>
AppendResult with details about whether or not it succeeded and more.
Exceptions
- UnknownEventSource
The type is not a discovered event source.
- EventStreamDoesNotBelongToEventSource
The stream is not declared by the event source.
- EventSourcesNotSupported
The implementation does not support event sources.
AppendWithNamedTags(EventSourceId, object, IEnumerable<NamedTag>, EventStreamType?, EventStreamId?, EventSourceType?, CorrelationId?, IEnumerable<string>?, ConcurrencyScope?, DateTimeOffset?, Subject?)
Append a single event with structured named tags.
public Task<AppendResult> AppendWithNamedTags(EventSourceId eventSourceId, object @event, IEnumerable<NamedTag> namedTags, EventStreamType? eventStreamType = null, EventStreamId? eventStreamId = null, EventSourceType? eventSourceType = null, CorrelationId? correlationId = null, IEnumerable<string>? tags = null, ConcurrencyScope? concurrencyScope = null, DateTimeOffset? occurred = null, Subject? subject = null)
Parameters
eventSourceIdEventSourceIdThe event source.
eventobjectThe event.
namedTagsIEnumerable<NamedTag>Structured named tags for the event.
eventStreamTypeEventStreamTypeOptional stream type.
eventStreamIdEventStreamIdOptional stream id.
eventSourceTypeEventSourceTypeOptional source type.
correlationIdCorrelationIdOptional correlation id.
tagsIEnumerable<string>Optional plain tags.
concurrencyScopeConcurrencyScopeOptional concurrency scope.
occurredDateTimeOffset?Optional occurred time.
subjectSubjectOptional subject.
Returns
- Task<AppendResult>
The append result.
Exceptions
- NamedTagsNotSupported
The implementation cannot append nonempty named tags.
CompleteStream(ClosedStreamScope, EventSequenceNumber?)
Manually complete a nonempty scope, optionally guarded by its expected tail.
public Task<Result<EventSequenceNumber, CompleteStreamError>> CompleteStream(ClosedStreamScope scope, EventSequenceNumber? expectedTailSequenceNumber = null)
Parameters
scopeClosedStreamScopeThe scope to close.
expectedTailSequenceNumberEventSequenceNumberThe expected scope tail, or null for no guard.
Returns
- Task<Result<EventSequenceNumber, CompleteStreamError>>
The sequence tail at closure, or a completion error.
Remarks
Covering manual closures return AlreadyCompleted. Event-owned coverage alone still writes a manual closure, so later reopening events cannot undo the operator's explicit decision.
Exceptions
- ClosedStreamScopesNotSupported
The implementation does not support scopes.
CompleteStream(EventStreamType, EventStreamId)
Complete a stream so that no further events can be appended to it.
public Task<Result<EventSequenceNumber, CompleteStreamError>> CompleteStream(EventStreamType eventStreamType, EventStreamId eventStreamId)
Parameters
eventStreamTypeEventStreamTypeThe EventStreamType identifying the stream's type.
eventStreamIdEventStreamIdThe EventStreamId identifying the stream within the type.
Returns
- Task<Result<EventSequenceNumber, CompleteStreamError>>
A Result<TResult, TError> containing the tail EventSequenceNumber at the moment of completion on success, or a CompleteStreamError describing why the operation was rejected.
Remarks
The default stream — All paired with the default EventStreamId — can never be completed and will return
DefaultStreamCannotBeCompleted. Completing an already-completed stream returns
AlreadyCompleted and leaves the stream in its completed state. After a successful completion any subsequent
append targeting the same stream results in a constraint violation of type StreamClosed.
GetClosedStreams(ClosedStreamScope?)
Inspect closed scopes within optional dimensions.
public Task<IImmutableList<ClosedStream>> GetClosedStreams(ClosedStreamScope? within = null)
Parameters
withinClosedStreamScopeThe scope filter, or null for all closures.
Returns
- Task<IImmutableList<ClosedStream>>
The matching closed scopes.
Exceptions
- ClosedStreamScopesNotSupported
The implementation does not support scopes.
GetForEventSourceIdAndEventTypes(EventSourceId, IEnumerable<EventType>, EventStreamType?, EventStreamId?, EventSourceType?)
Get all events for a specific EventSourceId.
public Task<IImmutableList<AppendedEvent>> GetForEventSourceIdAndEventTypes(EventSourceId eventSourceId, IEnumerable<EventType> filterEventTypes, EventStreamType? eventStreamType = null, EventStreamId? eventStreamId = null, EventSourceType? eventSourceType = null)
Parameters
eventSourceIdEventSourceIdEventSourceId to get for.
filterEventTypesIEnumerable<EventType>Collection of EventType to get for.
eventStreamTypeEventStreamTypeOptional EventStreamType to narrow to. Omit, or pass All, to not narrow.
eventStreamIdEventStreamIdOptional EventStreamId to narrow to. Omit, or pass Default, to not narrow.
eventSourceTypeEventSourceTypeOptional EventSourceType to narrow to. Omit, or pass Default or Unspecified, to not narrow.
Returns
- Task<IImmutableList<AppendedEvent>>
A collection of AppendedEvent.
GetFromSequenceNumber(EventSequenceNumber, EventSourceId?, IEnumerable<EventType>?)
Get all events after and including the given EventSequenceNumber with optional EventSourceId and IEnumerable<T> of EventType for filtering.
public Task<IImmutableList<AppendedEvent>> GetFromSequenceNumber(EventSequenceNumber sequenceNumber, EventSourceId? eventSourceId = null, IEnumerable<EventType>? filterEventTypes = null)
Parameters
sequenceNumberEventSequenceNumberThe EventSequenceNumber of the first event to get from.
eventSourceIdEventSourceIdThe optional EventSourceId.
filterEventTypesIEnumerable<EventType>The optional IEnumerable<T> of EventType.
Returns
- Task<IImmutableList<AppendedEvent>>
A collection of AppendedEvent.
GetMetadataAt(EventSequenceNumber, CancellationToken)
Reads metadata without event content at one locator. Authorize the read before calling.
public Task<EventMetadata?> GetMetadataAt(EventSequenceNumber sequenceNumber, CancellationToken cancellationToken = default)
Parameters
sequenceNumberEventSequenceNumberThe sequence locator.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task<EventMetadata>
The metadata, or null if the event does not exist.
Exceptions
- EventMetadataReadsNotSupported
The implementation does not support metadata reads.
GetMetadataAt(IEnumerable<EventSequenceNumber>, CancellationToken)
Reads metadata at up to 500 locators without event content. Missing events are omitted. Authorize the read before calling. Identity names resolve at read time, not append time.
public Task<IImmutableDictionary<EventSequenceNumber, EventMetadata>> GetMetadataAt(IEnumerable<EventSequenceNumber> sequenceNumbers, CancellationToken cancellationToken = default)
Parameters
sequenceNumbersIEnumerable<EventSequenceNumber>The sequence locators.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task<IImmutableDictionary<EventSequenceNumber, EventMetadata>>
The matching metadata keyed by locator.
Exceptions
- TooManyEventLocators
More than 500 locators were supplied.
- EventMetadataReadsNotSupported
The implementation does not support metadata reads.
GetNextSequenceNumber()
Get the next sequence number.
public Task<EventSequenceNumber> GetNextSequenceNumber()
Returns
- Task<EventSequenceNumber>
Next sequence number.
GetTailSequenceNumber(EventSourceId?, EventSourceType?, EventStreamType?, EventStreamId?, IEnumerable<EventType>?)
Get the sequence number of the last (tail) event in the sequence.
public Task<EventSequenceNumber> GetTailSequenceNumber(EventSourceId? eventSourceId = null, EventSourceType? eventSourceType = null, EventStreamType? eventStreamType = null, EventStreamId? eventStreamId = null, IEnumerable<EventType>? filterEventTypes = null)
Parameters
eventSourceIdEventSourceIdOptional EventSourceId to get for. If not specified, it will return the tail sequence number for all event sources.
eventSourceTypeEventSourceTypeOptional EventSourceType to get for. If not specified, it will return the tail sequence number for all event source types.
eventStreamTypeEventStreamTypeOptional EventStreamType to get for. If not specified, it will return the tail sequence number for all event stream types.
eventStreamIdEventStreamIdOptional EventStreamId to get for. If not specified, it will return the tail sequence number for all event streams.
filterEventTypesIEnumerable<EventType>Optional collection of EventType to filter by. If not specified, it will return the tail sequence number for all.
Returns
- Task<EventSequenceNumber>
Tail sequence number.
GetTailSequenceNumberForObserver(Type)
Get the sequence number of the last (tail) event in the sequence for a specific observer.
public Task<EventSequenceNumber> GetTailSequenceNumberForObserver(Type type)
Parameters
typeTypeType of observer to get for.
Returns
- Task<EventSequenceNumber>
Tail sequence number.
Remarks
This is based on the tail of the event types the observer is interested in.
HasEventsFor(EventSourceId)
Check if there are events for a specific EventSourceId.
public Task<bool> HasEventsFor(EventSourceId eventSourceId)
Parameters
eventSourceIdEventSourceIdEventSourceId to check for.
Returns
IsStreamCompleted(ClosedStreamScope)
Check whether a scope is covered by a persisted closure.
public Task<bool> IsStreamCompleted(ClosedStreamScope scope)
Parameters
scopeClosedStreamScopeThe scope to inspect.
Returns
Exceptions
- ClosedStreamScopesNotSupported
The implementation does not support scopes.
IsStreamCompleted(EventStreamType, EventStreamId)
Check whether a stream is covered by a persisted closure.
public Task<bool> IsStreamCompleted(EventStreamType eventStreamType, EventStreamId eventStreamId)
Parameters
eventStreamTypeEventStreamTypeThe stream type.
eventStreamIdEventStreamIdThe stream identifier.
Returns
Prepare(object)
Snapshots an event using this store's serializer and additional-information providers exactly once.
public Task<PreparedEvent> Prepare(object @event)
Parameters
eventobjectThe event to prepare.
Returns
- Task<PreparedEvent>
Content reusable for append and verification on this sequence instance.
Exceptions
- PreparedEventsNotSupported
This implementation does not support preparation.
Redact(EventSequenceNumber, RedactionReason)
Redact an event at a specific sequence number.
public Task Redact(EventSequenceNumber sequenceNumber, RedactionReason reason)
Parameters
sequenceNumberEventSequenceNumberEventSequenceNumber to redact.
reasonRedactionReasonReason for redacting.
Returns
Redact(EventSourceId, RedactionReason, params Type[])
Redact all events for a specific EventSourceId.
public Task Redact(EventSourceId eventSourceId, RedactionReason reason, params Type[] clrEventTypes)
Parameters
eventSourceIdEventSourceIdEventSourceId to redact.
reasonRedactionReasonReason for redacting.
clrEventTypesType[]Optionally any specific event types.
Returns
Revise(EventSequenceNumber, object)
Revise a specific event in the event sequence with new content.
public Task Revise(EventSequenceNumber sequenceNumber, object @event)
Parameters
sequenceNumberEventSequenceNumberEventSequenceNumber of the event to revise.
eventobjectThe event holding the revised content.
Returns
Remarks
The type of event has to be the same as the original event at the sequence number.
Its generational information is taken into account when revising.
VerifyContent(EventSequenceNumber, PreparedEvent, EventSourceId?)
Compares prepared content with the complete, strictly released content at an exact sequence number.
public Task<ContentVerificationResult> VerifyContent(EventSequenceNumber sequenceNumber, PreparedEvent preparedEvent, EventSourceId? eventSourceId = null)
Parameters
sequenceNumberEventSequenceNumberThe event to verify.
preparedEventPreparedEventContent prepared by this sequence, in the generation to compare.
eventSourceIdEventSourceIdOptional event source to require.
Returns
- Task<ContentVerificationResult>
Equal, different, or unavailable. Unavailable is never proof of a duplicate.
Exceptions
- PreparedEventBelongsToAnotherSequence
The content belongs to another sequence instance.