private async Task CommitIfRelevant(ProjectionPosition p)
        {
            if (!BatchingPolicy.ShouldCommit(p))
            {
                return;
            }

            await CommitState();

            if (p.LooksLikeLatestAvailableInput())
            {
                //performance testing:
                var now = DateTimeOffset.UtcNow;
                var timeSpentCatchingUp = now - _startedCatchingUpAt;
                Console.WriteLine($"Time taken to restore state of projection: {timeSpentCatchingUp.TotalSeconds} seconds");
            }
        }
示例#2
0
        //public readonly int EventsPerCommitWhenInputBuffered;

        //^-- callbacks for "onCatchupStatus" are dispatched as soon as the latest event in
        //the inputstream has been buffered, this is an "almost there"-state


        public bool ShouldCommit(ProjectionPosition p)
        {
            return(p.LooksLikeLatestAvailableInput() || p.UncommitedLength >= EventsPerCommitWhenCatchingUp);
        }