public AbstractV2ProjectionEngineTests(String pollingClientVersion = "1") { TestHelper.RegisterSerializerForFlatId <SampleAggregateId>(); _container = new WindsorContainer(); _container.AddFacility <TypedFactoryFacility>(); _container.Register( Component .For <ICommitPollingClient>() .ImplementedBy <CommitPollingClient2>() .LifestyleTransient(), Component .For <ICommitPollingClientFactory>() .AsFactory(), Component .For <ICommitEnhancer>() .UsingFactoryMethod(() => new CommitEnhancer(_identityConverter)), Component .For <ILogger>() .Instance(NullLogger.Instance)); switch (pollingClientVersion) { case "1": throw new NotSupportedException("Version 1 of projection engine was removed due to migration to NES6"); case "2": _pollingClientFactory = _container.Resolve <ICommitPollingClientFactory>(); break; default: throw new NotSupportedException("Version not supported"); } }
public ProcessManagerDispatcher( ProcessManagerConfiguration configuration, IMongoDatabase supportDatabase, ICommitPollingClientFactory pollingClientFactory, IPersistence persistence, ICommandBus commandBus, IMessageBus messageBus) { _configuration = configuration; _commandBus = commandBus; _checkpointCollection = supportDatabase.GetCollection <ProcessManagerCheckpoint>("sysPmCheckpoints"); _currentCheckpoint = _checkpointCollection.FindOneById(ProcessManagerId) ?? new ProcessManagerCheckpoint() { Id = ProcessManagerId, LastDispatchedPosition = 0 }; Logger = NullLogger.Instance; _client = pollingClientFactory.Create(persistence, "ProcessManager"); _client.AddConsumer("ProcessManager", Dispatch); _messageBus = messageBus; }
public ProjectionEngine( ICommitPollingClientFactory pollingClientFactory, IConcurrentCheckpointTracker checkpointTracker, IProjection[] projections, IHousekeeper housekeeper, IRebuildContext rebuildContext, INotifyCommitHandled notifyCommitHandled, ProjectionEngineConfig config) { Logger = NullLogger.Instance; _engineFatalErrors = new ConcurrentBag <string>(); _pollingClientFactory = pollingClientFactory; _checkpointTracker = checkpointTracker; _housekeeper = housekeeper; _rebuildContext = rebuildContext; _notifyCommitHandled = notifyCommitHandled; _config = config; if (_config.Slots[0] != "*") { projections = projections .Where(x => _config.Slots.Any(y => y == x.GetSlotName())) .ToArray(); } _allProjections = projections; _projectionsBySlot = projections .GroupBy(x => x.GetSlotName()) .ToDictionary(x => x.Key, x => x.OrderByDescending(p => p.Priority).ToArray()); _metrics = new ProjectionMetrics(_allProjections); _bucketToClient = new Dictionary <BucketInfo, ICommitPollingClient>(); RegisterHealthCheck(); }
/// <summary> /// This is the basic constructor for the projection engine. /// </summary> /// <param name="pollingClientFactory"></param> /// <param name="persistence"></param> /// <param name="checkpointTracker"></param> /// <param name="projections"></param> /// <param name="housekeeper"></param> /// <param name="notifyCommitHandled"></param> /// <param name="config"></param> /// <param name="logger"></param> /// <param name="loggerThreadContextManager"></param> public ProjectionEngine( ICommitPollingClientFactory pollingClientFactory, IPersistence persistence, IConcurrentCheckpointTracker checkpointTracker, IProjection[] projections, IHousekeeper housekeeper, INotifyCommitHandled notifyCommitHandled, ProjectionEngineConfig config, ILogger logger, ILoggerThreadContextManager loggerThreadContextManager) { if (projections == null) { throw new ArgumentNullException(nameof(projections)); } if (config == null) { throw new ArgumentNullException(nameof(config)); } _persistence = persistence ?? throw new ArgumentNullException(nameof(persistence)); _logger = logger; _loggerThreadContextManager = loggerThreadContextManager; var configErrors = config.Validate(); if (!String.IsNullOrEmpty(configErrors)) { throw new ArgumentException(configErrors, nameof(config)); } _engineFatalErrors = new ConcurrentBag <string>(); _pollingClientFactory = pollingClientFactory ?? throw new ArgumentNullException(nameof(pollingClientFactory)); _checkpointTracker = checkpointTracker ?? throw new ArgumentNullException(nameof(checkpointTracker)); _housekeeper = housekeeper ?? throw new ArgumentNullException(nameof(housekeeper)); _notifyCommitHandled = notifyCommitHandled ?? throw new ArgumentNullException(nameof(notifyCommitHandled)); _config = config; if (_config.Slots[0] != "*") { projections = projections .Where(x => _config.Slots.Any(y => y == x.Info.SlotName)) .ToArray(); } if (OfflineMode.Enabled) { //In offline mode we already have filtered out the projection. _allProjections = projections; } else { //we are not in offline mode, just use all projection that are not marked to //run only in offline mode logger.Info($"Projection engine is NOT in OFFLINE mode, projection engine will run only projection that are not marked for OfflineModel."); _allProjections = projections.Where(_ => !_.Info.OfflineProjection).ToArray(); } _projectionsBySlot = projections .GroupBy(x => x.Info.SlotName) .ToDictionary(x => x.Key, x => x.OrderByDescending(p => p.Priority).ToArray()); _bucketToClient = new Dictionary <BucketInfo, ICommitPollingClient>(); RegisterHealthCheck(); }