public Task HandlingEventAsync(IEvent @event)
 {
     _handlingActivity = ClaptrapActivitySource.Instance.StartActivity(HandleEvent)
                         .AddClaptrapTags(_claptrapDesign, _identity);
     _eventHandlingTimer = ClaptrapMetrics.MeasureEventHandling(_identity, @event);
     return(Task.CompletedTask);
 }
 public Task DeactivatingAsync()
 {
     _deactivatingActivity = ClaptrapActivitySource.Instance.StartActivity(Deactivate)
                             .AddClaptrapTags(_claptrapDesign, _identity);
     _deactivationTimer = ClaptrapMetrics.MeasureDeactivation(_identity);
     return(Task.CompletedTask);
 }
예제 #3
0
        private async Task ConsumeTasks()
        {
            while (true)
            {
                try
                {
                    var items = new List <BatchItem>(_options.BufferCount !.Value);
                    while (await _channel.Reader.WaitToReadAsync())
                    {
                        var last       = DateTimeOffset.UtcNow;
                        var windowTime = last.Add(_options.BufferTime !.Value);
                        while (items.Count < _options.BufferCount &&
                               windowTime > DateTimeOffset.UtcNow &&
                               _channel.Reader.TryRead(out var item))
                        {
                            items.Add(item);
                        }

                        if (items.Any())
                        {
                            try
                            {
                                ClaptrapMetrics.MeasureBatchOperatorGauge(_doManyFuncName, items.Count);
                                ClaptrapMetrics.MeasureBatchOperatorMaxCountGauge(_doManyFuncName,
                                                                                  _options.BufferCount !.Value);
                                using var _ = ClaptrapMetrics.MeasureBatchOperatorTime(_doManyFuncName);
                                await DoManyAsync(items);
                            }
                            finally
                            {
                                items.Clear();
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    _logger.LogError(e, "failed to run a batch");
                    await Task.Delay(TimeSpan.FromSeconds(5));
                }
            }
        }
 public async Task MigrateAsync()
 {
     using var _ = ClaptrapMetrics.MeasureStateLoaderMigration(_identity);
     await _stateLoaderMigration.MigrateAsync();
 }
 public async Task MigrateAsync()
 {
     using var _ = ClaptrapMetrics.MeasureEventSaverMigration(_identity);
     await _eventSaverMigration.MigrateAsync();
 }
예제 #6
0
 public Task DeactivatingAsync()
 {
     _deactivationTimer = ClaptrapMetrics.MeasureDeactivation(_identity);
     return(Task.CompletedTask);
 }
예제 #7
0
 public Task HandlingEventAsync(IEvent @event)
 {
     _eventHandlingTimer = ClaptrapMetrics.MeasureEventHandling(_identity, @event);
     return(Task.CompletedTask);
 }