Table of Contents

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

aggregate TAggregate

The aggregate to snapshot.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<ISnapshot>

The created snapshot.

Type Parameters

TAggregate

The type of aggregate.

GetLatestSnapshotAsync(string, CancellationToken)

Gets the latest snapshot for a stream.

Task<ISnapshot?> GetLatestSnapshotAsync(string streamId, CancellationToken cancellationToken)

Parameters

streamId string

The stream identifier.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<ISnapshot>

The latest snapshot or null if none exists.

RestoreFromSnapshotAsync<TAggregate>(ISnapshot, CancellationToken)

Restores an aggregate from a snapshot.

Task<TAggregate> RestoreFromSnapshotAsync<TAggregate>(ISnapshot snapshot, CancellationToken cancellationToken) where TAggregate : IAggregateRoot, IAggregateSnapshotSupport, new()

Parameters

snapshot ISnapshot

The snapshot to restore from.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<TAggregate>

The restored aggregate.

Type Parameters

TAggregate

The type of aggregate.

SaveSnapshotAsync(string, ISnapshot, CancellationToken)

Saves a snapshot to the store.

Task SaveSnapshotAsync(string streamId, ISnapshot snapshot, CancellationToken cancellationToken)

Parameters

streamId string

The stream identifier.

snapshot ISnapshot

The snapshot to save.

cancellationToken CancellationToken

The cancellation token.

Returns

Task

A task that represents the asynchronous save operation.