private async Task <T> GetUntracked(string bucket, string streamId) { ISnapshot snapshot = null; if (typeof(ISnapshotting).IsAssignableFrom(typeof(T))) { snapshot = await _snapstore.GetSnapshot <T>(bucket, streamId).ConfigureAwait(false); } var stream = await _store.GetStream <T>(bucket, streamId, snapshot).ConfigureAwait(false); // Get requires the stream exists if (stream == null || stream.StreamVersion == -1) { throw new NotFoundException($"Aggregate stream [{streamId}] in bucket [{bucket}] type {typeof(T).FullName} not found"); } return(await GetUntracked(stream).ConfigureAwait(false)); }
private async Task <T> GetUntracked(string bucket, string streamId) { Logger.Write(LogLevel.Debug, () => $"Retreiving aggregate id [{streamId}] in bucket [{bucket}] for type {typeof(T).FullName} in store"); ISnapshot snapshot = null; if (typeof(ISnapshotting).IsAssignableFrom(typeof(T))) { snapshot = await _snapstore.GetSnapshot <T>(bucket, streamId).ConfigureAwait(false); Logger.Write(LogLevel.Debug, () => { if (snapshot != null) { return($"Retreived snapshot for aggregate id [{streamId}] version {snapshot.Version}"); } return($"No snapshot found for aggregate id [{streamId}]"); }); } var stream = await _store.GetStream <T>(bucket, streamId, snapshot).ConfigureAwait(false); return(await GetUntracked(stream).ConfigureAwait(false)); }