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

eventStoreName EventStoreName

Name of the event store.

namespace EventStoreNamespaceName

Namespace for the event store.

eventSequenceId EventSequenceId

The identifier of the event sequence.

connection IChronicleConnection

IChronicleConnection for working with the connection to Chronicle.

eventTypes IEventTypes

Known IEventTypes.

constraints IConstraints

Known IConstraints.

eventSerializer IEventSerializer

The IEventSerializer for serializing events.

correlationIdAccessor ICorrelationIdAccessor

ICorrelationIdAccessor for getting correlation.

concurrencyScopeStrategies IConcurrencyScopeStrategies

IConcurrencyScopeStrategies for managing concurrency scopes.

causationManager ICausationManager

ICausationManager for getting causation.

unitOfWorkManager IUnitOfWorkManager

IUnitOfWorkManager for working with the unit of work.

identityProvider IIdentityProvider

IIdentityProvider for resolving identity for operations.

jsonSerializerOptions JsonSerializerOptions

JSON serializer options to use.

activitySource IActivitySource<EventSequence>

Optional IActivitySource<T> for tracing. Defaults to a source named SourceName when not provided.

sideEffectHandlers IReactorSideEffectHandlers

Optional handlers used to recognize synchronous reactor return types.

eventSources IEventSources

Optional 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

IObservable<IEnumerable<AppendedEventWithResult>>

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

EventSequenceId

SupportsIdempotentAppends

Gets a value indicating whether this implementation can append with an IdempotencyKey. Defaults to false.

public bool SupportsIdempotentAppends { get; }

Property Value

bool

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

ITransactionalEventSequence

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

eventSourceId EventSourceId

The EventSourceId to append for.

event object

The event.

eventStreamType EventStreamType

Optional EventStreamType to append to. Defaults to All.

eventStreamId EventStreamId

Optional EventStreamId to append to. Defaults to Default.

eventSourceType EventSourceType

Optional EventSourceType to append to. Defaults to Default.

correlationId CorrelationId

Optional CorrelationId of the event. Defaults to Current.

tags IEnumerable<string>

Optional collection of tags to associate with the event. Will be combined with any static tags from the event type.

concurrencyScope ConcurrencyScope

Optional ConcurrencyScope to use for concurrency control. Defaults to None.

occurred DateTimeOffset?

Optional DateTimeOffset specifying when the event occurred. If not set, the server will set it to approximately the time of append.

subject Subject

Optional Subject identifying the target the event is about. Used as the identity for compliance concerns such as PII encryption keys. When omitted, the eventSourceId is 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

eventSourceId EventSourceId

The EventSourceId to append for.

events IEnumerable<object>

Collection of events to append.

eventStreamType EventStreamType

Optional EventStreamType to append to. Defaults to All.

eventStreamId EventStreamId

Optional EventStreamId to append to. Defaults to Default.

eventSourceType EventSourceType

Optional EventSourceType to append to. Defaults to Default.

correlationId CorrelationId

Optional CorrelationId of the event. Defaults to Current.

tags IEnumerable<string>

Optional collection of tags to associate with all events. Will be combined with any static tags from the event types.

concurrencyScope ConcurrencyScope

Optional ConcurrencyScope to use for concurrency control. Defaults to None.

occurred DateTimeOffset?

Optional DateTimeOffset specifying when the events occurred. If not set, the server will set it to approximately the time of append.

subject Subject

Optional 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

events IEnumerable<EventForEventSourceId>

Collection of EventForEventSourceId to append.

correlationId CorrelationId

Optional CorrelationId of the event. Defaults to Current.

tags IEnumerable<string>

Optional collection of tags to associate with all events. Will be combined with any static tags from the event types.

concurrencyScopes IDictionary<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

events IEnumerable<EventForEventSourceId>

The events in append order.

correlationId CorrelationId

Optional correlation id.

tags IEnumerable<string>

Optional shared tags.

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

eventSourceId EventSourceId

The event source.

events IEnumerable<object>

The events.

idempotencyKey IdempotencyKey

The key identifying this batch.

eventStreamType EventStreamType

Optional stream type.

eventStreamId EventStreamId

Optional stream id.

eventSourceType EventSourceType

Optional source type.

correlationId CorrelationId

Optional correlation id.

tags IEnumerable<string>

Optional plain tags.

concurrencyScope ConcurrencyScope

Optional concurrency scope.

occurred DateTimeOffset?

Optional occurred time.

subject Subject

Optional 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

eventSourceId EventSourceId

The event source.

events IEnumerable<object>

The events.

idempotencyKey IdempotencyKey

The key identifying this batch.

namedTags IEnumerable<NamedTag>

Structured named tags for every event.

eventStreamType EventStreamType

Optional stream type.

eventStreamId EventStreamId

Optional stream id.

eventSourceType EventSourceType

Optional source type.

correlationId CorrelationId

Optional correlation id.

tags IEnumerable<string>

Optional plain tags.

concurrencyScope ConcurrencyScope

Optional concurrency scope.

occurred DateTimeOffset?

Optional occurred time.

subject Subject

Optional 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

eventSource Type

The type of the IEventSource to append through.

eventSourceId EventSourceId

The EventSourceId of the event source instance.

events IEnumerable<object>

The events to append.

eventStream string

Optional name of a stream declared by the event source.

eventStreamId EventStreamId

Optional EventStreamId within the stream. The format is left to the caller.

correlationId CorrelationId

Optional CorrelationId of the events.

tags IEnumerable<string>

Optional tags to associate with the events.

concurrencyScope ConcurrencyScope

Optional ConcurrencyScope. When not set it is narrowed to the dimensions the definition declares.

occurred DateTimeOffset?

Optional time the events occurred.

subject Subject

Optional 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

eventSourceId EventSourceId

The event source.

events IEnumerable<object>

The events.

namedTags IEnumerable<NamedTag>

Structured named tags for every event.

eventStreamType EventStreamType

Optional stream type.

eventStreamId EventStreamId

Optional stream id.

eventSourceType EventSourceType

Optional source type.

correlationId CorrelationId

Optional correlation id.

tags IEnumerable<string>

Optional plain tags.

concurrencyScope ConcurrencyScope

Optional concurrency scope.

occurred DateTimeOffset?

Optional occurred time.

subject Subject

Optional 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

events IEnumerable<EventForEventSourceId>

The events, including their own named tags.

namedTags IEnumerable<NamedTag>

Structured named tags shared by all events.

correlationId CorrelationId

Optional correlation id.

tags IEnumerable<string>

Optional plain tags.

concurrencyScopes IDictionary<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

events IEnumerable<EventForEventSourceId>

The events in append order.

namedTags IEnumerable<NamedTag>

Shared named tags.

correlationId CorrelationId

Optional correlation id.

tags IEnumerable<string>

Optional shared tags.

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

eventSourceId EventSourceId

The event source.

event object

The event.

idempotencyKey IdempotencyKey

The key identifying this append.

eventStreamType EventStreamType

Optional stream type.

eventStreamId EventStreamId

Optional stream id.

eventSourceType EventSourceType

Optional source type.

correlationId CorrelationId

Optional correlation id.

tags IEnumerable<string>

Optional plain tags.

concurrencyScope ConcurrencyScope

Optional concurrency scope.

occurred DateTimeOffset?

Optional occurred time.

subject Subject

Optional 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

eventSourceId EventSourceId

The event source.

event object

The event.

idempotencyKey IdempotencyKey

The key identifying this append.

namedTags IEnumerable<NamedTag>

Structured named tags for the event.

eventStreamType EventStreamType

Optional stream type.

eventStreamId EventStreamId

Optional stream id.

eventSourceType EventSourceType

Optional source type.

correlationId CorrelationId

Optional correlation id.

tags IEnumerable<string>

Optional plain tags.

concurrencyScope ConcurrencyScope

Optional concurrency scope.

occurred DateTimeOffset?

Optional occurred time.

subject Subject

Optional 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

eventSourceId EventSourceId

The event source.

preparedEvent PreparedEvent

The content prepared by this sequence.

eventStreamType EventStreamType

Optional stream type.

eventStreamId EventStreamId

Optional stream id.

eventSourceType EventSourceType

Optional source type.

correlationId CorrelationId

Optional correlation id.

tags IEnumerable<string>

Optional tags.

concurrencyScope ConcurrencyScope

Optional concurrency scope.

occurred DateTimeOffset?

Optional occurrence time.

subject Subject

Optional 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

eventSource Type

The type of the IEventSource to append through.

eventSourceId EventSourceId

The EventSourceId of the event source instance.

preparedEvent PreparedEvent

The content prepared by this sequence.

eventStream string

Optional name of a stream declared by the event source.

eventStreamId EventStreamId

Optional EventStreamId within the stream. The format is left to the caller.

correlationId CorrelationId

Optional CorrelationId of the event.

tags IEnumerable<string>

Optional tags to associate with the event.

concurrencyScope ConcurrencyScope

Optional ConcurrencyScope. When not set it is narrowed to the dimensions the definition declares.

occurred DateTimeOffset?

Optional time the event occurred.

subject Subject

Optional 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

eventSource Type

The type of the IEventSource to append through.

eventSourceId EventSourceId

The EventSourceId of the event source instance.

event object

The event to append.

eventStream string

Optional name of a stream declared by the event source.

eventStreamId EventStreamId

Optional EventStreamId within the stream. The format is left to the caller.

correlationId CorrelationId

Optional CorrelationId of the event.

tags IEnumerable<string>

Optional tags to associate with the event.

concurrencyScope ConcurrencyScope

Optional ConcurrencyScope. When not set it is narrowed to the dimensions the definition declares.

occurred DateTimeOffset?

Optional time the event occurred.

subject Subject

Optional 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

eventSourceId EventSourceId

The event source.

event object

The event.

namedTags IEnumerable<NamedTag>

Structured named tags for the event.

eventStreamType EventStreamType

Optional stream type.

eventStreamId EventStreamId

Optional stream id.

eventSourceType EventSourceType

Optional source type.

correlationId CorrelationId

Optional correlation id.

tags IEnumerable<string>

Optional plain tags.

concurrencyScope ConcurrencyScope

Optional concurrency scope.

occurred DateTimeOffset?

Optional occurred time.

subject Subject

Optional 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

scope ClosedStreamScope

The scope to close.

expectedTailSequenceNumber EventSequenceNumber

The 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

eventStreamType EventStreamType

The EventStreamType identifying the stream's type.

eventStreamId EventStreamId

The 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

within ClosedStreamScope

The 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

eventSourceId EventSourceId

EventSourceId to get for.

filterEventTypes IEnumerable<EventType>

Collection of EventType to get for.

eventStreamType EventStreamType

Optional EventStreamType to narrow to. Omit, or pass All, to not narrow.

eventStreamId EventStreamId

Optional EventStreamId to narrow to. Omit, or pass Default, to not narrow.

eventSourceType EventSourceType

Optional 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

sequenceNumber EventSequenceNumber

The EventSequenceNumber of the first event to get from.

eventSourceId EventSourceId

The optional EventSourceId.

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

sequenceNumber EventSequenceNumber

The sequence locator.

cancellationToken CancellationToken

The 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

sequenceNumbers IEnumerable<EventSequenceNumber>

The sequence locators.

cancellationToken CancellationToken

The 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

eventSourceId EventSourceId

Optional EventSourceId to get for. If not specified, it will return the tail sequence number for all event sources.

eventSourceType EventSourceType

Optional EventSourceType to get for. If not specified, it will return the tail sequence number for all event source types.

eventStreamType EventStreamType

Optional EventStreamType to get for. If not specified, it will return the tail sequence number for all event stream types.

eventStreamId EventStreamId

Optional EventStreamId to get for. If not specified, it will return the tail sequence number for all event streams.

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

type Type

Type 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

eventSourceId EventSourceId

EventSourceId to check for.

Returns

Task<bool>

True if it has, false if not.

IsStreamCompleted(ClosedStreamScope)

Check whether a scope is covered by a persisted closure.

public Task<bool> IsStreamCompleted(ClosedStreamScope scope)

Parameters

scope ClosedStreamScope

The scope to inspect.

Returns

Task<bool>

True if covered.

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

eventStreamType EventStreamType

The stream type.

eventStreamId EventStreamId

The stream identifier.

Returns

Task<bool>

True if covered.

Prepare(object)

Snapshots an event using this store's serializer and additional-information providers exactly once.

public Task<PreparedEvent> Prepare(object @event)

Parameters

event object

The 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

sequenceNumber EventSequenceNumber

EventSequenceNumber to redact.

reason RedactionReason

Reason for redacting.

Returns

Task

Awaitable Task.

Redact(EventSourceId, RedactionReason, params Type[])

Redact all events for a specific EventSourceId.

public Task Redact(EventSourceId eventSourceId, RedactionReason reason, params Type[] clrEventTypes)

Parameters

eventSourceId EventSourceId

EventSourceId to redact.

reason RedactionReason

Reason for redacting.

clrEventTypes Type[]

Optionally any specific event types.

Returns

Task

Awaitable Task.

Revise(EventSequenceNumber, object)

Revise a specific event in the event sequence with new content.

public Task Revise(EventSequenceNumber sequenceNumber, object @event)

Parameters

sequenceNumber EventSequenceNumber

EventSequenceNumber of the event to revise.

event object

The event holding the revised content.

Returns

Task

Awaitable Task.

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

sequenceNumber EventSequenceNumber

The event to verify.

preparedEvent PreparedEvent

Content prepared by this sequence, in the generation to compare.

eventSourceId EventSourceId

Optional 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.