Ejemplo n.º 1
0
        internal AnalyticsSender(Uri endpoint, AnalyticsConfig config, AnalyticsEnvironment environment, string gcpKey,
                                 string eventSource, TimeSpan maxEventQueueDelta, int maxEventQueueSize,
                                 IDispatchExceptionStrategy dispatchExceptionStrategy, HttpClient httpClient)
        {
            _endpoint                  = endpoint;
            _config                    = config;
            _environment               = environment;
            _gcpKey                    = gcpKey;
            _eventSource               = eventSource;
            _maxEventQueueSize         = maxEventQueueSize;
            _dispatchExceptionStrategy = dispatchExceptionStrategy;
            _httpClient                = httpClient;

            Task.Factory.StartNew(async() =>
            {
                while (true)
                {
                    await DispatchEventQueue();
                    await Task.Delay(maxEventQueueDelta, _timedDispatchCancelTokenSrc.Token);
                }
            }, _timedDispatchCancelTokenSrc.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default);
        }
 /// <summary>
 /// Sets the strategy for handling HTTP exceptions during analytic dispatch.
 /// </summary>
 public AnalyticsSenderBuilder With(IDispatchExceptionStrategy strategy)
 {
     _dispatchExceptionStrategy = strategy ?? throw new ArgumentNullException();
     return(this);
 }