public AtomicProjectionMetricsConfigurer(
     IProjectionTargetCheckpointLoader checkPointLoader,
     IAtomicReadModelFactory readModelFactory,
     AtomicProjectionCheckpointManager atomicProjectionCheckpointManager,
     AtomicReadModelVersionLoader versionLoader)
 {
     _checkPointLoader = checkPointLoader;
     _atomicProjectionCheckpointManager = atomicProjectionCheckpointManager;
     _versionLoader    = versionLoader;
     _readModelFactory = readModelFactory;
 }
예제 #2
0
        public async Task Verify_flush_has_always_last_version_dispatched_even_with_events_of_other_aggregates()
        {
            await GenerateSomeChangesetsAndReturnLatestsChangeset().ConfigureAwait(false);

            //Generate a changeset, that has an event that was not handled by the readmodel.
            await GenerateAtomicAggregateCreatedEvent().ConfigureAwait(false);

            //And finally check if everything is projected
            await CreateSutAndStartProjectionEngineAsync(1).ConfigureAwait(false);

            //we need to wait to understand if it was projected
            GetTrackerAndWaitForChangesetToBeProjected("SimpleTestAtomicReadModel");

            //now we need to monitor for checkpoint collection to be populated.
            DateTime startWait = DateTime.UtcNow;

            while (DateTime.UtcNow.Subtract(startWait).TotalSeconds < 5)
            {
                try
                {
                    AtomicProjectionCheckpointManager newTracker = new AtomicProjectionCheckpointManager(_db);
                    //this new tracker reload from db
                    if (newTracker.GetCheckpoint("SimpleTestAtomicReadModel") == lastUsedPosition)
                    {
                        return; //test succeeded, it was saved.
                    }

                    Thread.Sleep(200);
                }
#pragma warning disable RCS1075 // Avoid empty catch clause that catches System.Exception.
                catch (Exception)
                {
                    //Ignore any error, the checkpoint coudl not be still saved. (we can improve the test reading directly the mongo collection)
                }
#pragma warning restore RCS1075 // Avoid empty catch clause that catches System.Exception.
            }

            //if we reach here, no flush was made...
            Assert.Fail("No flushing occurred");
        }