Beispiel #1
0
 public void DecDefault()
 {
     for (var i = 0; i < _opIterations; i++)
     {
         _gauge.Dec();
     }
 }
Beispiel #2
0
 public void DecDefault_Int64()
 {
     for (var i = 0; i < _opIterations; i++)
     {
         _gaugeInt64.Dec();
     }
 }
Beispiel #3
0
        public async Task <QueueItem <T> > DequeueAsync(CancellationToken token)
        {
            await _signal.WaitAsync(token).ConfigureAwait(false);

            _workItems.TryDequeue(out var workItem);
            _elementsInQueue?.Dec();
            LastDequeuedAt = DateTimeOffset.UtcNow;
            ItemCount--;
            return(workItem);
        }
    public async Task <Func <CancellationToken, Task> > DequeueAsync(
        CancellationToken cancellationToken)
    {
        await _signal.WaitAsync(cancellationToken);

        _workItems.TryDequeue(out var workItem);
        _queuedItemsGauge.Dec();

        return(workItem);
    }
Beispiel #5
0
        public async Task Invoke(HttpContext context)
        {
            _inFlightGauge.Inc();

            try
            {
                await _next(context);
            }
            finally
            {
                _inFlightGauge.Dec();
            }
        }
Beispiel #6
0
        private async Task PeriodicLicenseChecksAsync()
        {
            var consecutiveFailures = 0;
            var isFirstCheck        = true;

            do
            {
                logger.LogTrace("Performing license check");
                try
                {
                    await licenseValidator.ValidateLicenseAsync(licenseKey,
                                                                moduleInstanceName, hostName, hubName, DateTime.UtcNow, serviceStopping.Token);

                    logger.LogTrace("License is valid");
                    consecutiveLicenseCheckFailures.Set(0);
                    remainingConsecutiveLicenseCheckFailures.Set(maxConsecutiveCheckFailures);
                }
                catch (OperationCanceledException)
                {
                    logger.LogTrace("Canceled in-progress license check");
                }
                catch (Exception ex)
                {
                    consecutiveFailures++;
                    logger.LogCritical(ex, isFirstCheck
                        ? $"Startup license validation failed"
                        : $"Post-startup license validation failed {consecutiveFailures} consecutive time(s) of max {maxConsecutiveCheckFailures}");
                    consecutiveLicenseCheckFailures.Inc();
                    remainingConsecutiveLicenseCheckFailures.Dec();
                    if (isFirstCheck || consecutiveFailures > maxConsecutiveCheckFailures)
                    {
                        throw;
                    }
                }
                isFirstCheck = false;

                await Task.Delay(licenseCheckInterval, serviceStopping.Token);
            } while (!serviceStopping.IsCancellationRequested);
        }
Beispiel #7
0
 public static void Dec(this IGauge gauge, double decrement, DateTimeOffset timestamp)
 {
     gauge.Dec(decrement, timestamp.ToUnixTime());
 }
 public static void Dec(this IGauge <long> gauge, long decrement, DateTimeOffset timestamp)
 {
     gauge.Dec(decrement, timestamp.ToUnixTimeMilliseconds());
 }