Example #1
0
        private IEnumerable <Commit> ShowLogs(IEnumerable <Commit> commits, Checkpoint from, Checkpoint to, ProjectionWrapper[] projections)
        {
            bool      first           = true;
            ICommit   commitProcessed = null;
            long      noOfCommits     = 0;
            Stopwatch timer           = new Stopwatch();

            timer.Start();
            foreach (var commit in commits)
            {
                noOfCommits++;
                if (first)
                {
                    if (from.IsUndefined)
                    {
                        log.Info("Rebuild started from the beginning");
                    }
                    else
                    {
                        log.Info(string.Format("Rebuild started from {0} due to checkpoint {1}", commit.CommitId, from));
                    }
                    first = false;
                }

                yield return(commit);

                commitProcessed = commit;
                if (noOfCommits % 1000 == 0)
                {
                    log.Info(string.Format("{0} commits were processed {1}", noOfCommits, timer.Elapsed));
                }
                if (noOfCommits % 10000 == 0)
                {
                    log.Debug("Projection statistics" + Environment.NewLine + ProjectionWrapper.GetStatistic(projections, take: 3));
                }
            }
            if (commitProcessed != null)
            {
                log.Info(string.Format("{0} commits were processed {1:mm\\:ss\\.ff}", noOfCommits, timer.Elapsed));
                if (to.IsUndefined)
                {
                    log.Info(string.Format("Rebuild finished on the end {0}", commitProcessed.CommitId));
                }
                else
                {
                    log.Info(string.Format("Rebuild finished on checkpoint {0}", to));
                }
                log.Info("Projection statistics" + Environment.NewLine + ProjectionWrapper.GetStatistic(projections, take: 20, takeEvents: 5));
            }
        }
 private void RebuildCommit(ICommit commit, ProjectionWrapper[] projections)
 {
     foreach (var evt in commit.Events.Select(e => e.Body).OfType<IEvent>())
         foreach (var projection in projections)
             projection.Handle(evt);
 }
        private IEnumerable<Commit> ShowLogs(IEnumerable<Commit> commits, Checkpoint from, Checkpoint to, ProjectionWrapper[] projections)
        {
            bool first = true;
            ICommit commitProcessed = null;
            long noOfCommits = 0;
            Stopwatch timer = new Stopwatch();
            timer.Start();
            foreach (var commit in commits)
            {
                noOfCommits++;
                if (first)
                {
                    if (from.IsUndefined)
                        log.Info("Rebuild started from the beginning");
                    else
                        log.Info(string.Format("Rebuild started from {0} due to checkpoint {1}", commit.CommitId, from));
                    first = false;
                }

                yield return commit;

                commitProcessed = commit;
                if (noOfCommits % 1000 == 0)
                    log.Info(string.Format("{0} commits were processed {1}", noOfCommits, timer.Elapsed));
                if (noOfCommits % 10000 == 0)
                    log.Debug("Projection statistics" + Environment.NewLine + ProjectionWrapper.GetStatistic(projections, take: 3));
            }
            if (commitProcessed != null)
            {
                log.Info(string.Format("{0} commits were processed {1:mm\\:ss\\.ff}", noOfCommits, timer.Elapsed));
                if (to.IsUndefined)
                    log.Info(string.Format("Rebuild finished on the end {0}", commitProcessed.CommitId));
                else
                    log.Info(string.Format("Rebuild finished on checkpoint {0}", to));
                log.Info("Projection statistics" + Environment.NewLine + ProjectionWrapper.GetStatistic(projections, take: 20, takeEvents: 5));
            }
        }