Пример #1
0
        public RebuildProjection_Job CreateJob(ProjectionVersion version, VersionRequestTimebox timebox)
        {
            job.Name = $"urn:{boundedContext.Name}:{context.Tenant}:{job.Name}:{version.ProjectionName}_{version.Hash}_{version.Revision}";

            job.BuildInitialData(() =>
            {
                var data       = new RebuildProjection_JobData();
                data.Timestamp = timebox.RequestStartAt;
                data.DueDate   = timebox.FinishRequestUntil;
                data.Version   = version;

                return(data);
            });

            return(job);
        }
Пример #2
0
        public async Task SaveAggregateCommitsAsync(IEnumerable <EventStream> eventStreams, RebuildProjection_JobData Data)
        {
            List <Task> indexingTasks = new List <Task>();

            foreach (EventStream stream in eventStreams)
            {
                if (Data.IsCanceled)
                {
                    return;
                }

                try
                {
                    foreach (AggregateCommit arCommit in stream.Commits)
                    {
                        Task indexAction = progressTracker.CompleteActionWithProgressSignalAsync(() => index.IndexAsync(arCommit, Data.Version));
                        indexingTasks.Add(indexAction);
                    }
                }
                catch (Exception ex) when(logger.WarnException(ex, () => $"{stream.ToString()} was skipped when rebuilding {Data.Version.ProjectionName}."))
                {
                }
            }

            await Task.WhenAll(indexingTasks.ToArray()).ConfigureAwait(false);
        }