Exemple #1
0
        private async Task NotifyClusterAsync(string eventTypeId, string paginationToken, IClusterOperations cluster, CancellationToken cancellationToken)
        {
            var progress = new RebuildProjection_JobData.EventPaging(eventTypeId, paginationToken, progressTracker.Processed, progressTracker.TotalEvents);

            Data.MarkEventTypeProgress(progress);
            Data.Timestamp = DateTimeOffset.UtcNow;
            Data           = await cluster.PingAsync(Data, cancellationToken).ConfigureAwait(false);

            var progressSignal = progressTracker.GetProgressSignal();

            signalPublisher.Publish(progressSignal);
        }
Exemple #2
0
        private async Task <bool> RebuildEventsAsync(string eventTypeId, IClusterOperations cluster, CancellationToken cancellationToken)
        {
            RebuildProjection_JobData.EventPaging paging = Data.EventTypePaging.Where(et => et.Type.Equals(eventTypeId, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();

            unchecked
            {
                ulong pagingProcessedCount = Data.EventTypePaging.Select(p => p.ProcessedCount).DefaultIfEmpty().Aggregate((x, y) => x + y);
                progressTracker.Processed = pagingProcessedCount;
            }

            string paginationToken = paging?.PaginationToken;
            LoadIndexRecordsResult indexRecordsResult = await eventToAggregateIndex.EnumerateRecordsAsync(eventTypeId, paginationToken).ConfigureAwait(false); // TODO: Think about cassandra exception here. Such exceptions MUST be handled in the concrete impl of the IndexStore

            IEnumerable <EventStream> eventStreams = await rebuildingRepository.LoadEventsAsync(indexRecordsResult.Records, Data.Version).ConfigureAwait(false);

            await rebuildingRepository.SaveAggregateCommitsAsync(eventStreams, Data).ConfigureAwait(false);

            await NotifyClusterAsync(eventTypeId, indexRecordsResult.PaginationToken, cluster, cancellationToken).ConfigureAwait(false);

            var hasMoreRecords = indexRecordsResult.Records.Any();

            return(hasMoreRecords);
        }