Esempio n. 1
0
        /// <summary>
        /// Construct a sink posting to the specified database.
        /// </summary>
        /// <param name="batchSizeLimit">The maximum number of events to include in a single batch.</param>
        /// <param name="period">The time to wait between checking for event batches.</param>
        protected PeriodicBatchingSink(int batchSizeLimit, TimeSpan period)
        {
            _batchSizeLimit = batchSizeLimit;
            _queue          = new BoundedConcurrentQueue <LogEvent>();
            _status         = new BatchedConnectionStatus(period);

            _timer = new PortableTimer(cancel => OnTick());
        }
Esempio n. 2
0
        /// <summary>
        /// Construct a sink posting to the specified database.
        /// </summary>
        /// <param name="batchSizeLimit">The maximum number of events to include in a single batch.</param>
        /// <param name="period">The time to wait between checking for event batches.</param>
        protected PeriodicBatchingSink(int batchSizeLimit, TimeSpan period)
        {
            _batchSizeLimit = batchSizeLimit;
            _queue          = new ConcurrentQueue <LogEvent>();
            _status         = new BatchedConnectionStatus(period);

#if NO_TIMER
            _timer = new PortableTimer(cancel => OnTick());
#else
            _timer = new Timer(s => OnTick(), null, -1, -1);
#endif

#if !NO_APPDOMAIN
            AppDomain.CurrentDomain.DomainUnload       += OnAppDomainUnloading;
            AppDomain.CurrentDomain.ProcessExit        += OnAppDomainUnloading;
            AppDomain.CurrentDomain.UnhandledException += OnAppDomainUnloading;
#endif
        }
Esempio n. 3
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());
        }