Ejemplo n.º 1
0
        public async Task <ProjectionsInfo> CheckAndRebuildProjections(CancellationToken token)
        {
            var persistedProjectionsInfo = await this.LoadProjectionsInfo();

            var strategy        = this._targetContainer.Strategy;
            var memory          = new NonserializingMemoryStorageConfig();
            var memoryContainer = memory.CreateNuclear(strategy).Container;

            var generatedProjectionInfos = this.GeneratedProjectionInfosFromProjectors(token, memoryContainer, strategy);

            var partitionedProjections = PartitionedProjectionsInfo.Partition(persistedProjectionsInfo.Infos, generatedProjectionInfos, this._storage);

            this.PrintProjectionsStatus(partitionedProjections);

            await this.DeleteObsolete(partitionedProjections.Obsolete, this._targetContainer);

            await this.RebuildProjections(partitionedProjections.NeedRebuild, memoryContainer, token);

            if (partitionedProjections.NeedRebuild.Count > 0 || partitionedProjections.Obsolete.Count > 0)
            {
                var newProjectionsInfo = new ProjectionsInfo();
                newProjectionsInfo.Infos.UnionWith(partitionedProjections.ReadyForUse);
                newProjectionsInfo.Infos.UnionWith(partitionedProjections.NeedRebuild);
                await this._storage.SaveEntityAsync(this._name, newProjectionsInfo);

                persistedProjectionsInfo = newProjectionsInfo;
            }
            return(persistedProjectionsInfo);
        }
Ejemplo n.º 2
0
 public async Task Init(CancellationToken token)
 {
     this._projectionsInfo = await this._rebuilder.CheckAndRebuildProjections(token);
 }