Beispiel #1
0
        internal Client(string writeKey, Config config, IRequestHandler requestHandler)
        {
            this.Statistics = new Statistics();

            this._writeKey = writeKey;
            this._config   = config;

            if (requestHandler == null)
            {
                if (config.Send)
                {
                    if (config.MaxRetryTime.HasValue)
                    {
                        requestHandler = new BlockingRequestHandler(this, config.Timeout, new Backo(max: (Convert.ToInt32(config.MaxRetryTime.Value.TotalSeconds) * 1000), jitter: 5000));
                    }
                    else
                    {
                        requestHandler = new BlockingRequestHandler(this, config.Timeout);
                    }
                }
                else
                {
                    requestHandler = new FakeRequestHandler(this);
                }
            }

            IBatchFactory batchFactory = new SimpleBatchFactory(this._writeKey);

            if (config.Async)
            {
                _flushHandler = new AsyncIntervalFlushHandler(batchFactory, requestHandler, config.MaxQueueSize, config.FlushAt, config.FlushIntervalInMillis, config.Threads);
            }
            else
            {
                _flushHandler = new BlockingFlushHandler(batchFactory, requestHandler);
            }
        }