Пример #1
0
        PeriodicBatchingSink(PeriodicBatchingSinkOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            if (options.BatchSizeLimit <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(options), "The batch size limit must be greater than zero.");
            }
            if (options.Period <= TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException(nameof(options), "The period must be greater than zero.");
            }

            _batchSizeLimit        = options.BatchSizeLimit;
            _queue                 = new BoundedConcurrentQueue <LogEvent>(options.QueueLimit);
            _status                = new BatchedConnectionStatus(options.Period);
            _eagerlyEmitFirstEvent = options.EagerlyEmitFirstEvent;
            _timer                 = new PortableTimer(cancel => OnTick());
        }
Пример #2
0
 /// <summary>
 /// Construct a <see cref="PeriodicBatchingSink"/>.
 /// </summary>
 /// <param name="batchedSink">A <see cref="IBatchedLogEventSink"/> to send log event batches to. Batches and empty
 /// batch notifications will not be sent concurrently. When the <see cref="PeriodicBatchingSink"/> is disposed,
 /// it will dispose this object if possible.</param>
 /// <param name="options">Options controlling behavior of the sink.</param>
 public PeriodicBatchingSink(IBatchedLogEventSink batchedSink, PeriodicBatchingSinkOptions options)
     : this(options)
 {
     _batchedLogEventSink = batchedSink ?? throw new ArgumentNullException(nameof(batchedSink));
 }