Table of Contents

Interface IEventSequence

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

Defines the client event sequence.

public interface IEventSequence
Extension Methods

Properties

AppendOperations

Gets an observable that emits a collection of AppendedEventWithResult after each append operation.

IObservable<IEnumerable<AppendedEventWithResult>> AppendOperations { get; }

Property Value

IObservable<IEnumerable<AppendedEventWithResult>>

Remarks

Both Append(EventSourceId, object, EventStreamType?, EventStreamId?, EventSourceType?, CorrelationId?, IEnumerable<string>?, ConcurrencyScope?, DateTimeOffset?) and AppendMany(EventSourceId, IEnumerable<object>, EventStreamType?, EventStreamId?, EventSourceType?, CorrelationId?, IEnumerable<string>?, ConcurrencyScope?, DateTimeOffset?) 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.

EventSequenceId Id { get; }

Property Value

EventSequenceId

Transactional

Gets the transactional event sequence.

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?)

Append a single event to the event store.

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)

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.

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?)

Append a collection of events to the event store as a transaction.

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)

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.

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.

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.

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

Get all events for a specific EventSourceId.

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

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.

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.

GetNextSequenceNumber()

Get the next sequence number.

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.

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.

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.

Task<bool> HasEventsFor(EventSourceId eventSourceId)

Parameters

eventSourceId EventSourceId

EventSourceId to check for.

Returns

Task<bool>

True if it has, false if not.

Redact(EventSequenceNumber, RedactionReason)

Redact an event at a specific sequence number.

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.

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.