Interface ISnapshotRepository
- Namespace
- Stratara.Abstractions.EventSourcing
- Assembly
- Stratara.Abstractions.dll
Repository over the snapshot table — periodic state captures that let the
aggregation service skip replaying every event from the start of a stream.
public interface ISnapshotRepository
- Extension Methods
Methods
AddAsync(Snapshot, CancellationToken)
Append a snapshot. Caller is responsible for the transactional save.
Task AddAsync(Snapshot snapshot, CancellationToken cancellationToken = default)
Parameters
snapshotSnapshotcancellationTokenCancellationToken
Returns
GetAsync(Guid, string, long?, CancellationToken)
Returns the latest snapshot for streamId of the aggregate type identified
by aggregateTypeName with a version no greater than
toVersion, or null if none exists.
Task<Snapshot?> GetAsync(Guid streamId, string aggregateTypeName, long? toVersion = null, CancellationToken cancellationToken = default)
Parameters
streamIdGuidThe stream to load a snapshot for.
aggregateTypeNamestringThe (assembly-)qualified name of the aggregate type to match.
toVersionlong?Upper version bound (inclusive), or
nullfor the latest.cancellationTokenCancellationTokenPropagated to the query.
Returns
Remarks
The type match is version-independent: assembly version / culture / public-key-token segments are ignored so an assembly rev-bump does not invalidate existing snapshots. Scoping the read to the aggregate type is required — two aggregate types keyed on the same stream id must never rehydrate from each other's snapshot.
GetLatestVersionOrDefaultAsync(Guid, string, CancellationToken)
Returns the version of the most recent snapshot for the stream of the aggregate type
identified by aggregateTypeName (version-independent match), or 0.
Task<long> GetLatestVersionOrDefaultAsync(Guid streamId, string aggregateTypeName, CancellationToken cancellationToken = default)
Parameters
streamIdGuidThe stream to inspect.
aggregateTypeNamestringThe (assembly-)qualified name of the aggregate type to match.
cancellationTokenCancellationTokenPropagated to the query.