internal Client(string writeKey, Config config, IRequestHandler requestHandler) { this.Statistics = new Statistics(); this._writeKey = writeKey; this._config = config; if (requestHandler == null) { if (config.Send) { requestHandler = new FakeRequestHandler(this); } else { requestHandler = new BlockingRequestHandler(this, config.Timeout); } } 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); } }
/// <summary> /// Initializes a new instance of the <see cref="Client" /> class. /// Creates a new REST client with a specified API writeKey and default config. /// </summary> /// <param name="writeKey">The API write key.</param> /// <param name="config">The config file to initialize the client with.</param> public Client(string writeKey, Config config) { if (string.IsNullOrEmpty(writeKey)) { throw new InvalidOperationException("Please supply a valid writeKey to initialize."); } this.Statistics = new Statistics(); this.writeKey = writeKey; this.config = config; IRequestHandler requestHandler = new BlockingRequestHandler(this, config.Timeout); IBatchFactory batchFactory = new SimpleBatchFactory(this.writeKey); #if UNITY_5_3_OR_NEWER var gameObject = new UnityEngine.GameObject("Segment", typeof(MonoBehaviourFlushHandler)); var monoBehaviourFlushHandler = gameObject.GetComponent <MonoBehaviourFlushHandler>(); monoBehaviourFlushHandler.Initialize(batchFactory, requestHandler, config.MaxQueueSize, config.Async); this.flushHandler = monoBehaviourFlushHandler; this.Succeeded += monoBehaviourFlushHandler.ClientSuccess; #else if (this.config.Async) { this.flushHandler = new AsyncFlushHandler(batchFactory, requestHandler, this.config.MaxQueueSize); } else { this.flushHandler = new BlockingFlushHandler(batchFactory, requestHandler); } #endif }
/// <summary> /// Creates a new REST client with a specified API writeKey and default config /// </summary> /// <param name="writeKey"></param> /// <param name="config"></param> public Client(string writeKey, Config config) { if (String.IsNullOrEmpty(writeKey)) throw new InvalidOperationException("Please supply a valid writeKey to initialize."); this.Statistics = new Statistics(); this._writeKey = writeKey; this._config = config; IRequestHandler requestHandler = new BlockingRequestHandler(config.Host, config.Timeout); IBatchFactory batchFactory = new SimpleBatchFactory(this._writeKey); requestHandler.Succeeded += (action) => { this.Statistics.Succeeded += 1; if (Succeeded != null) Succeeded(action); }; requestHandler.Failed += (action, e) => { this.Statistics.Failed += 1; if (Failed != null) Failed(action, e); }; if (config.Async) _flushHandler = new AsyncFlushHandler(batchFactory, requestHandler, config.MaxQueueSize); else _flushHandler = new BlockingFlushHandler(batchFactory, requestHandler); }
/// <summary> /// Creates a new REST client with a specified API writeKey and default config /// </summary> /// <param name="writeKey"></param> /// <param name="config"></param> public Client(string writeKey, Config config) { if (string.IsNullOrEmpty(writeKey)) throw new InvalidOperationException("Please supply a valid writeKey to initialize."); Statistics = new Statistics(); WriteKey = writeKey; Config = config; IRequestHandler requestHandler = new BlockingRequestHandler(config.Host, config.Timeout); IBatchFactory batchFactory = new SimpleBatchFactory(WriteKey); requestHandler.Succeeded += action => { Statistics.Succeeded += 1; Succeeded?.Invoke(action); }; requestHandler.Failed += (action, e) => { Statistics.Failed += 1; Failed?.Invoke(action, e); }; if (config.Async) { _flushHandler = new AsyncFlushHandler(batchFactory, requestHandler, config.MaxQueueSize); } else { _flushHandler = new BlockingFlushHandler(batchFactory, requestHandler); } }
/// <summary> /// Creates a new REST client with a specified API secret and default options /// </summary> /// <param name="secret"></param> /// <param name="options"></param> public Client(string secret, Options options) { if (String.IsNullOrEmpty(secret)) throw new InvalidOperationException("Please supply a valid secret to initialize."); this.Statistics = new Statistics(); this._secret = secret; this._options = options; IRequestHandler requestHandler = new BlockingRequestHandler(this, options.Timeout); IBatchFactory batchFactory = new SimpleBatchFactory(this._secret); if (options.Async) _flushHandler = new AsyncFlushHandler(batchFactory, requestHandler, options.MaxQueueSize); else _flushHandler = new BlockingFlushHandler(batchFactory, requestHandler); }
/// <summary> /// Creates a new REST client with a specified API writeKey and default config /// </summary> /// <param name="writeKey"></param> /// <param name="config"></param> public Client(string writeKey, Config config) { if (String.IsNullOrEmpty(writeKey)) { throw new InvalidOperationException("Please supply a valid writeKey to initialize."); } this.Statistics = new Statistics(); this._writeKey = writeKey; this._config = config; IRequestHandler requestHandler = new BlockingRequestHandler(config.Host, config.Timeout); IBatchFactory batchFactory = new SimpleBatchFactory(this._writeKey); requestHandler.Succeeded += (action) => { this.Statistics.Succeeded += 1; if (Succeeded != null) { Succeeded(action); } }; requestHandler.Failed += (action, e) => { this.Statistics.Failed += 1; if (Failed != null) { Failed(action, e); } }; if (config.Async) { _flushHandler = new AsyncFlushHandler(batchFactory, requestHandler, config.MaxQueueSize); } else { _flushHandler = new BlockingFlushHandler(batchFactory, requestHandler); } }
/// <summary> /// Creates a new REST client with a specified API secret and default options /// </summary> /// <param name="secret"></param> /// <param name="options"></param> public Client(string secret, Options options) { if (String.IsNullOrEmpty(secret)) throw new InvalidOperationException("Please supply a valid secret to initialize."); this.Statistics = new Statistics(); this._secret = secret; this._options = options; IRequestHandler requestHandler = new WWWRequestHandler(this); IBatchFactory batchFactory = new SimpleBatchFactory(this._secret); _flushHandler = new BatchingFlushHandler( batchFactory, requestHandler, options.MinBatchSize, options.MaxQueueSize, options.MinSendBatchInterval ); }
/// <summary> /// Creates a new REST client with a specified API secret and default options /// </summary> /// <param name="secret"></param> /// <param name="options"></param> public Client(string secret, Options options) { if (String.IsNullOrEmpty(secret)) { throw new InvalidOperationException("Please supply a valid secret to initialize."); } this.Statistics = new Statistics(); this._secret = secret; this._options = options; IRequestHandler requestHandler = new WWWRequestHandler(this); IBatchFactory batchFactory = new SimpleBatchFactory(this._secret); _flushHandler = new BatchingFlushHandler( batchFactory, requestHandler, options.MinBatchSize, options.MaxQueueSize, options.MinSendBatchInterval ); }
internal Client(string writeKey, Config config, IRequestHandler requestHandler) { this.Statistics = new Statistics(); this._writeKey = writeKey; this._config = config; requestHandler = requestHandler ?? new BlockingRequestHandler(this, config.Timeout); IBatchFactory batchFactory = new SimpleBatchFactory(this._writeKey); if (config.Async) { #if NET35 _flushHandler = new AsyncFlushHandler(batchFactory, requestHandler, config.MaxQueueSize, config.MaxBatchSize, config.FlushIntervalInMillis); #else _flushHandler = new AsyncIntervalFlushHandler(batchFactory, requestHandler, config.MaxQueueSize, config.MaxBatchSize, config.FlushIntervalInMillis); #endif } else { _flushHandler = new BlockingFlushHandler(batchFactory, requestHandler); } }
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); } }
/// <summary> /// Creates a new REST client with a specified API secret and default options /// </summary> /// <param name="secret"></param> /// <param name="options"></param> public Client(string secret, Options options) { if (String.IsNullOrEmpty(secret)) { throw new InvalidOperationException("Please supply a valid secret to initialize."); } this.Statistics = new Statistics(); this._secret = secret; this._options = options; IRequestHandler requestHandler = new BlockingRequestHandler(this, options.Timeout); IBatchFactory batchFactory = new SimpleBatchFactory(this._secret); if (options.Async) { _flushHandler = new AsyncFlushHandler(batchFactory, requestHandler, options.MaxQueueSize); } else { _flushHandler = new BlockingFlushHandler(batchFactory, requestHandler); } }
/// <summary> /// Creates a new REST client with a specified API writeKey and default config /// </summary> /// <param name="writeKey"></param> /// <param name="config"></param> public Client(string writeKey, Config config) { if (String.IsNullOrEmpty(writeKey)) { throw new InvalidOperationException("Please supply a valid writeKey to initialize."); } this.Statistics = new Statistics(); this._writeKey = writeKey; this._config = config; IRequestHandler requestHandler = new BlockingRequestHandler(this, config.Timeout); IBatchFactory batchFactory = new SimpleBatchFactory(this._writeKey); if (config.Async) { _flushHandler = new AsyncFlushHandler(batchFactory, requestHandler, config.MaxQueueSize, config.MaxBatchSize); } else { _flushHandler = new BlockingFlushHandler(batchFactory, requestHandler); } }
/// <summary> /// Creates a new REST client with a specified API writeKey and default config /// </summary> /// <param name="writeKey"></param> /// <param name="config"></param> public Client(string writeKey, Config config) { if (string.IsNullOrEmpty(writeKey)) { throw new InvalidOperationException("Please supply a valid writeKey to initialize."); } Statistics = new Statistics(); _writeKey = writeKey; _config = config; IRequestHandler requestHandler = new BlockingRequestHandler(this, config.Timeout); IBatchFactory batchFactory = new SimpleBatchFactory(_writeKey); if (config.Async) { _flushHandler = new AsyncFlushHandler(batchFactory, requestHandler, config.MaxQueueSize); } else { _flushHandler = new BlockingFlushHandler(batchFactory, requestHandler); } }