Interface IEventStoreVersionProbe
- Namespace
- Excalibur.EventSourcing
- Assembly
- Excalibur.EventSourcing.Abstractions.dll
Optional IEventStore capability that reports the highest event version held for a stream, without loading the stream.
public interface IEventStoreVersionProbe
Remarks
This exists to resolve one ambiguity the read surface cannot express. When an aggregate is rehydrated from a snapshot, the events after the snapshot are loaded; an empty result means either that the snapshot is already at the head of the stream -- the normal and common case -- or that the stream stops below the snapshot, so the snapshot describes a state the events can no longer account for. Both return zero rows, and nothing in that result distinguishes them.
Implement this only where the answer is cheap -- an indexed maximum over the stream's version column, not a scan of the events themselves. A store that cannot answer cheaply should not implement it: the capability is resolved through GetService(Type) on IEventStore, so a store that does not provide it simply is not probed, and the load behaves exactly as it does without this capability. There is no third state and no obligation on any provider.
Resolve it through GetService(Type) rather than testing the store's type: a store is commonly reached through a decorator, and a type test reports the decorator's own interface list rather than the capabilities of the store beneath it. A decorator that cannot answer for the whole stream must not forward this capability -- a tiered store whose hot tier has been trimmed would otherwise report a maximum that omits the archived range and make a correctly-archived stream look truncated.
Methods
GetMaxVersionAsync(string, string, CancellationToken)
Gets the highest event version stored for the aggregate stream.
ValueTask<long> GetMaxVersionAsync(string aggregateId, string aggregateType, CancellationToken cancellationToken)
Parameters
aggregateIdstringThe aggregate identifier.
aggregateTypestringThe aggregate type name.
cancellationTokenCancellationTokenToken to observe for cancellation.