Esempio n. 1
0
        public ConcurrentProjectionsEngine(
            IConcurrentCheckpointTracker checkpointTracker,
            IProjection[] projections,
            IPollingClient client,
            IHousekeeper housekeeper,
            IRebuildContext rebuildContext,
            INotifyCommitHandled notifyCommitHandled,
            ProjectionEngineConfig config)
        {
            _checkpointTracker   = checkpointTracker;
            _client              = client;
            _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);
        }
        public ProjectionEngine(
            Func <IPersistStreams, CommitPollingClient> pollingClientFactory,
            IConcurrentCheckpointTracker checkpointTracker,
            IProjection[] projections,
            IHousekeeper housekeeper,
            IRebuildContext rebuildContext,
            INotifyCommitHandled notifyCommitHandled,
            ProjectionEngineConfig config)
        {
            _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);
            _clients        = new List <CommitPollingClient>();
            _bucketToClient = new Dictionary <BucketInfo, CommitPollingClient>();
        }
Esempio n. 3
0
        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();
        }
Esempio n. 4
0
        /// <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();
        }