public ConcurrentEventSender( int eventBufferSize, uint maxConcurrency, int batchSize, TimeSpan noEventsDelay, Func <IEnumerable <EventDataType>, long, CancellationToken, Task> transmitterProc, IHealthReporter healthReporter) { this.events = new BlockingCollection <EventDataType>(eventBufferSize); this.ValidateConstructorParameters( eventBufferSize, maxConcurrency, batchSize, noEventsDelay, transmitterProc, healthReporter); this.maxConcurrency = maxConcurrency; this.batchSize = batchSize; this.noEventsDelay = noEventsDelay; this.TransmitterProc = transmitterProc; this.capacityWarningThreshold = (int)Math.Ceiling(0.9m * eventBufferSize); this.healthReporter = healthReporter; // Probably does not make sense to report event loss more often than once per second. this.eventLossThrottle = new TimeSpanThrottle(TimeSpan.FromSeconds(1)); this.cts = new CancellationTokenSource(); Task.Run(() => this.EventConsumerAsync(this.cts.Token)); }
public BufferingEventListener(IConfigurationProvider configurationProvider, IHealthReporter healthReporter) { if (configurationProvider == null) { throw new ArgumentNullException("configurationProvider"); } if (healthReporter == null) { throw new ArgumentNullException("healthReporter"); } this.healthReporter = healthReporter; this.errorReportingThrottle = new TimeSpanThrottle(TimeSpan.FromSeconds(1)); lock (this) // See OnEventSourceCreated() for explanation why we are locking on 'this' here. { this.Disabled = !configurationProvider.HasConfiguration; this.EnableInitialSources(); this.constructed = true; } }