Exemplo n.º 1
0
            private IEventPipeline GetPipeline()
            {
                if (_pipeline == null)
                {
                    _pipeline = _pipelineFactory.Setup();
                }

                return(_pipeline);
            }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new instance of the eventbus
        /// </summary>
        /// <param name="pipelineFactory"></param>
        /// <param name="pipelineId"></param>
        public EventBus(IPipelineFactory pipelineFactory, string pipelineId)
        {
            _pipelineFactory = pipelineFactory;
            PipelineId       = pipelineId;

            var storage = GlobalConfiguration.Configuration.Resolve <IStorage>();

            _metricService = new MetricService(storage, pipelineId);

            _queue  = new EventQueue();
            _logger = LoggerConfiguration.Setup
                      (
                s =>
            {
                s.AddWriter(new ProcessedEventMetricCounter(_metricService, pipelineId));
                s.AddWriter(new ActiveWorkersLogWriter(pipelineId));
                s.AddWriter(new LogEventStatisticWriter(pipelineId));
            }
                      );

            _metricService.SetMetric(new Metric(MetricType.ThreadCount, "Active Workers", _processors.Count));
            _metricService.SetMetric(new Metric(MetricType.QueueSize, "Events in Queue", _queue.Count));
            _metricService.SetPipelineHeartbeat();

            var options = _pipelineFactory.Options.Merge(GlobalConfiguration.Configuration.GetOptions());

            _minProcessors = options.MinProcessors;

            _cleanupLock = new DispatcherLock();
            _dispatcher  = new EventBusPorcessDispatcher(_processors, _queue, () => new EventProcessor(new EventPipelineWorker(_queue, () => _pipelineFactory.Setup(), _logger, _metricService), CleanupProcessors, _logger), _logger, _metricService, options);
            RunDispatcher();
        }