private async Task <ProjectionStream> LoadProjectionStreamAsync(Type projectionType, ProjectionVersion version, IBlobId projectionId, SnapshotMeta snapshotMeta) { ISnapshot loadedSnapshot = await snapshotStore.LoadAsync(version.ProjectionName, projectionId, version).ConfigureAwait(false); Func <ISnapshot> loadSnapshot = () => projectionType.IsSnapshotable() ? loadedSnapshot : new NoSnapshot(projectionId, version.ProjectionName); return(await LoadProjectionStreamAsync(version, projectionId, snapshotMeta, loadSnapshot).ConfigureAwait(false)); }
async Task <ProjectionStream> LoadProjectionStreamAsync(Type projectionType, IBlobId projectionId) { string projectionName = projectionType.GetContractId(); ReadResult <ProjectionVersions> result = GetProjectionVersions(projectionName); if (result.IsSuccess) { ProjectionVersion liveVersion = result.Data.GetLive(); if (liveVersion is null) { log.Warn(() => $"Unable to find projection `live` version. ProjectionId:{projectionId} ProjectionName:{projectionName} ProjectionType:{projectionType.Name}{Environment.NewLine}AvailableVersions:{Environment.NewLine}{result.Data.ToString()}"); return(ProjectionStream.Empty()); } ISnapshot snapshot = null; if (projectionType.IsSnapshotable()) { snapshot = await snapshotStore.LoadAsync(projectionName, projectionId, liveVersion).ConfigureAwait(false); } else { snapshot = new NoSnapshot(projectionId, projectionName); } ProjectionStream stream = await LoadProjectionStreamAsync(projectionType, liveVersion, projectionId, snapshot); return(stream); } return(ProjectionStream.Empty()); }