Example #1
0
 public static Task <SnapshotInfo> GetAsync(
     this ISnapshotStore snapshots,
     string snapshotPartitionId,
     long version
     )
 {
     return(snapshots.GetAsync(snapshotPartitionId, version, CancellationToken.None));
 }
Example #2
0
        public async Task <IActionResult> Get(CancellationToken cancellationToken)
        {
            var snapshots = await _store.GetAsync(cancellationToken);

            return(Ok(new
            {
                Value = snapshots
            }));
        }
Example #3
0
        private async Task <SnapshotInfo> LoadSnapshot(string snapshotId, CancellationToken cancellationToken)
        {
            SnapshotInfo si = null;

            if (_upToIndex.HasValue)
            {
                si = await _snapshots.GetAsync(snapshotId, _upToIndex.Value, cancellationToken)
                     .ConfigureAwait(false);
            }
            else
            {
                si = await _snapshots.GetLastAsync(snapshotId, cancellationToken)
                     .ConfigureAwait(false);
            }
            return(si);
        }
        private async Task <int> TryRestoreAggregateFromSnapshot <T>(string id, T aggregate) where T : AggregateRoot
        {
            if (!_snapshotStrategy.IsSnapshotable(typeof(T)))
            {
                return(-1);
            }

            var snapshot = await _snapshotStore.GetAsync(id).ConfigureAwait(false);

            if (snapshot == null)
            {
                return(-1);
            }

            aggregate.Invoke("Restore", snapshot);
            return(snapshot.Version);
        }
        public async Task loading_missing_snapshot_should_return_empty()
        {
            var snapshot = await _snapshots.GetAsync("no-one", 1);

            Assert.Null(snapshot);
        }