Table of Contents

Interface ITimeTravelQuery

Namespace
Excalibur.EventSourcing.Queries
Assembly
Excalibur.EventSourcing.dll

Provides time-travel query capabilities for event-sourced aggregates.

public interface ITimeTravelQuery

Remarks

Time-travel queries enable examining the state of aggregates at any point in their history, either by timestamp or by version number. This is useful for auditing, debugging, historical reporting, and temporal queries.

Implementations should leverage the IEventStore to load events up to the specified point and replay them against the aggregate.

Methods

GetEventsAtPointInTimeAsync(string, string, DateTimeOffset, CancellationToken)

Gets events for an aggregate up to a specific point in time.

ValueTask<IReadOnlyList<StoredEvent>> GetEventsAtPointInTimeAsync(string aggregateId, string aggregateType, DateTimeOffset pointInTime, CancellationToken cancellationToken)

Parameters

aggregateId string

The aggregate identifier.

aggregateType string

The aggregate type name.

pointInTime DateTimeOffset

The timestamp to query up to (inclusive).

cancellationToken CancellationToken

Cancellation token.

Returns

ValueTask<IReadOnlyList<StoredEvent>>

The events that occurred up to the specified point in time.

GetEventsAtVersionAsync(string, string, long, CancellationToken)

Gets events for an aggregate up to a specific version.

ValueTask<IReadOnlyList<StoredEvent>> GetEventsAtVersionAsync(string aggregateId, string aggregateType, long version, CancellationToken cancellationToken)

Parameters

aggregateId string

The aggregate identifier.

aggregateType string

The aggregate type name.

version long

The version to query up to (inclusive).

cancellationToken CancellationToken

Cancellation token.

Returns

ValueTask<IReadOnlyList<StoredEvent>>

The events up to and including the specified version.

GetEventsInTimeRangeAsync(string, string, DateTimeOffset, DateTimeOffset, CancellationToken)

Gets events for an aggregate within a specific time range.

ValueTask<IReadOnlyList<StoredEvent>> GetEventsInTimeRangeAsync(string aggregateId, string aggregateType, DateTimeOffset from, DateTimeOffset to, CancellationToken cancellationToken)

Parameters

aggregateId string

The aggregate identifier.

aggregateType string

The aggregate type name.

from DateTimeOffset

The start of the time range (inclusive).

to DateTimeOffset

The end of the time range (inclusive).

cancellationToken CancellationToken

Cancellation token.

Returns

ValueTask<IReadOnlyList<StoredEvent>>

The events within the specified time range.