Interface ISnapshotManager
- Namespace
- Excalibur.EventSourcing
- Assembly
- Excalibur.EventSourcing.Abstractions.dll
Manages snapshot creation and restoration for aggregates.
public interface ISnapshotManager
Methods
CreateSnapshotAsync<TAggregate>(TAggregate, CancellationToken)
Creates a snapshot for an aggregate.
Task<ISnapshot> CreateSnapshotAsync<TAggregate>(TAggregate aggregate, CancellationToken cancellationToken) where TAggregate : IAggregateRoot, IAggregateSnapshotSupport
Parameters
aggregateTAggregateThe aggregate to snapshot.
cancellationTokenCancellationTokenThe cancellation token.
Returns
Type Parameters
TAggregateThe type of aggregate.
GetLatestSnapshotAsync(string, CancellationToken)
Gets the latest snapshot for a stream.
Task<ISnapshot?> GetLatestSnapshotAsync(string streamId, CancellationToken cancellationToken)
Parameters
streamIdstringThe stream identifier.
cancellationTokenCancellationTokenThe cancellation token.
Returns
RestoreFromSnapshotAsync<TAggregate>(ISnapshot, CancellationToken)
Restores an aggregate from a snapshot.
Task<TAggregate> RestoreFromSnapshotAsync<TAggregate>(ISnapshot snapshot, CancellationToken cancellationToken) where TAggregate : IAggregateRoot, IAggregateSnapshotSupport, new()
Parameters
snapshotISnapshotThe snapshot to restore from.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task<TAggregate>
The restored aggregate.
Type Parameters
TAggregateThe type of aggregate.
SaveSnapshotAsync(string, ISnapshot, CancellationToken)
Saves a snapshot to the store.
Task SaveSnapshotAsync(string streamId, ISnapshot snapshot, CancellationToken cancellationToken)
Parameters
streamIdstringThe stream identifier.
snapshotISnapshotThe snapshot to save.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task
A task that represents the asynchronous save operation.