Ejemplo n.º 1
0
        public void Start()
        {
            _log.Info($"Starting {nameof(HeartbeatCashoutTimeoutFinisherPeriodicalHandler)}",
                      context: _settings);

            _timer.Start();
        }
        public void Start()
        {
            _log.Info($"Starting {nameof(HeartbeatCashoutStarterPeriodicalHandler)}",
                      context: _settings);

            _timer.Start();
            _startedAt = DateTime.UtcNow;
        }
        public AzureTableLogPersistenceQueue(
            [NotNull] INoSQLTableStorage <LogEntity> storage,
            [NotNull] string logName,
            [NotNull] ILogFactory lastResortLogFactory,
            TimeSpan maxBatchLifetime,
            int batchSizeThreshold)
        {
            if (string.IsNullOrEmpty(logName))
            {
                throw new ArgumentException("Should be not empty string", nameof(logName));
            }
            if (maxBatchLifetime < TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException(nameof(maxBatchLifetime), maxBatchLifetime, "Should be positive time span");
            }
            if (batchSizeThreshold < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(batchSizeThreshold), batchSizeThreshold, "Should be positive number");
            }

            _maxBatchLifetime = maxBatchLifetime;

            _storage = storage ?? throw new ArgumentNullException(nameof(storage));

            _batchBlock        = new BatchBlock <LogEntity>(batchSizeThreshold);
            _groupBatchBlock   = new TransformManyBlock <LogEntity[], IGrouping <string, LogEntity> >(batch => GroupEntriesBatch(batch));
            _persistGroupBlock = new ActionBlock <IGrouping <string, LogEntity> >(
                // ReSharper disable once ConvertClosureToMethodGroup
                group => PersistEntriesGroup(group),
                new ExecutionDataflowBlockOptions
            {
                MaxDegreeOfParallelism = 2
            });

            _batchBlock.LinkTo(_groupBatchBlock);
            _groupBatchBlock.LinkTo(_persistGroupBlock);

            ExtendBatchExpiration();

            _timer = new TimerTrigger(logName, TimeSpan.FromMilliseconds(50), lastResortLogFactory)
                     .DisableTelemetry();
            _timer.Triggered += HandleTimerTriggered;
            _timer.Start();
        }
 public void Start()
 {
     _timer.Start();
 }