Beispiel #1
0
 public RtqTaskCounterEventConsumer(RtqTaskCounterStateManager stateManager,
                                    IHandleTasksMetaStorage handleTasksMetaStorage,
                                    RtqMonitoringPerfGraphiteReporter perfGraphiteReporter)
 {
     this.stateManager           = stateManager;
     this.handleTasksMetaStorage = handleTasksMetaStorage;
     this.perfGraphiteReporter   = perfGraphiteReporter;
 }
 public RtqTaskCounterGraphiteReporter(RtqTaskCounterStateManager stateManager, IGraphiteClient graphiteClient, [NotNull] string graphitePathPrefix)
 {
     if (string.IsNullOrEmpty(graphitePathPrefix))
     {
         throw new InvalidOperationException("graphitePathPrefix is empty");
     }
     this.stateManager       = stateManager;
     this.graphiteClient     = graphiteClient;
     this.graphitePathPrefix = graphitePathPrefix;
 }
        public (/*[NotNull]*/ IEventFeedsRunner, /*[NotNull]*/ RtqTaskCounterStateManager) RunEventFeeding(CancellationToken cancellationToken)
        {
            var stateManager  = new RtqTaskCounterStateManager(logger, serializer, taskDataRegistry, stateStorage, settings, offsetInterpreter, perfGraphiteReporter);
            var eventConsumer = new RtqTaskCounterEventConsumer(stateManager, handleTasksMetaStorage, perfGraphiteReporter);
            IBladesBuilder <string> bladesBuilder = BladesBuilder.New(eventSource, eventConsumer, logger);

            foreach (var bladeId in stateManager.Blades)
            {
                bladesBuilder = bladesBuilder.WithBlade(bladeId.BladeKey, bladeId.Delay);
            }
            var eventFeedsRunner = eventFeedFactory
                                   .WithOffsetType <string>()
                                   .WithEventType(bladesBuilder)
                                   .WithOffsetInterpreter(offsetInterpreter)
                                   .WithOffsetStorageFactory(bladeId => stateManager.CreateOffsetStorage(bladeId))
                                   .WithSingleLeaderElectionKey(stateManager.CompositeFeedKey)
                                   .RunFeeds(settings.DelayBetweenEventFeedingIterations, cancellationToken);

            return(eventFeedsRunner, stateManager);
        }