Exemplo n.º 1
0
        public async Task <SnapshotEnvelope> LoadSnapshotAsync(string stream, CancellationToken cancellationToken = default)
        {
            var stopWatch = new Stopwatch();

            stopWatch.Start();

            var snapshotDescriptor = await _snapshotRepository.LoadSnapshotAsync(stream, cancellationToken);

            if (snapshotDescriptor == null)
            {
                return(null);
            }

            var snapshot = DeserializeSnapshot(stream, snapshotDescriptor);

            stopWatch.Stop();
            _logger.LogDebug("SnapshotStore.LoadSnapshotAsync for {Stream} took {ElapsedMilliseconds} ms", stream, stopWatch.ElapsedMilliseconds);

            return(new SnapshotEnvelope(snapshot, snapshotDescriptor.AggregateVersion, stream));
        }