public TelemetryAPI(ISplitioHttpClient splitioHttpClient, string telemetryURL, ITelemetryRuntimeProducer telemetryRuntimeProducer, ISplitLogger log = null) { _splitioHttpClient = splitioHttpClient; _telemetryURL = telemetryURL; _telemetryRuntimeProducer = telemetryRuntimeProducer; _log = log ?? WrapperAdapter.GetLogger(typeof(TelemetryAPI)); }
public AuthApiClient(string url, string apiKey, long connectionTimeOut, ISplitioHttpClient splitioHttpClient = null, ISplitLogger log = null) { _url = url; _splitioHttpClient = splitioHttpClient ?? new SplitioHttpClient(apiKey, connectionTimeOut); _log = log ?? WrapperAdapter.GetLogger(typeof(AuthApiClient)); }
public AuthApiClient(string url, string apiKey, ISplitioHttpClient splitioHttpClient, ITelemetryRuntimeProducer telemetryRuntimeProducer, ISplitLogger log = null) { _url = url; _splitioHttpClient = splitioHttpClient; _telemetryRuntimeProducer = telemetryRuntimeProducer; _log = log ?? WrapperAdapter.GetLogger(typeof(AuthApiClient)); }
private async Task ConnectAsync() { try { UpdateFinishedConnection(finished: false); _splitHttpClient = new SplitioHttpClient(new Dictionary <string, string> { { "Accept", "text/event-stream" } }); _cancellationTokenSource = new CancellationTokenSource(); using (var response = await _splitHttpClient.GetAsync(_url, HttpCompletionOption.ResponseHeadersRead, _cancellationTokenSource.Token)) { _log.Debug($"Response from {_url}: {response.StatusCode}"); if (response.IsSuccessStatusCode) { try { using (var stream = await response.Content.ReadAsStreamAsync()) { _log.Info($"Connected to {_url}"); UpdateStatus(connected: true); DispatchConnected(); await ReadStreamAsync(stream); } } catch (Exception ex) { _log.Error($"Error reading stream: {ex.Message}"); Disconnect(reconnect: true); return; } } } } catch (Exception ex) { _log.Error($"Error connecting to {_url}: {ex.Message}"); } finally { UpdateFinishedConnection(finished: true); } _log.Debug("Finished Event Source client ConnectAsync."); Disconnect(); }
public EventSourceClient(INotificationParser notificationParser, IWrapperAdapter wrapperAdapter, ISplitioHttpClient splitHttpClient, ITelemetryRuntimeProducer telemetryRuntimeProducer, ITasksManager tasksManager, ISplitLogger log = null) { _notificationParser = notificationParser; _wrapperAdapter = wrapperAdapter; _splitHttpClient = splitHttpClient; _log = log ?? WrapperAdapter.GetLogger(typeof(EventSourceClient)); _telemetryRuntimeProducer = telemetryRuntimeProducer; _tasksManager = tasksManager; _firstEvent = true; }
private async Task ConnectAsync() { try { _wrapperAdapter.TaskDelay(Convert.ToInt32(_backOff.GetInterval()) * 1000).Wait(); _splitHttpClient = new SplitioHttpClient(new Dictionary <string, string> { { "Accept", "text/event-stream" } }); _cancellationTokenSource = new CancellationTokenSource(); using (var response = await _splitHttpClient.GetAsync(_url, HttpCompletionOption.ResponseHeadersRead, _cancellationTokenSource.Token)) { UpdateFinishedConnection(finished: false); try { using (var stream = await response.Content.ReadAsStreamAsync()) { _log.Info($"Connected to {_url}"); UpdateStatus(connected: true); _backOff.Reset(); DispatchConnected(); await ReadStreamAsync(stream); } } catch (Exception ex) { _log.Error($"Error reading stream: {ex.Message}"); ReconnectAsync(); } } } catch (Exception ex) { _log.Error($"Error connecting to {_url}: {ex.Message}"); } _log.Debug("Finished Event Source client ConnectAsync."); Disconnect(); UpdateFinishedConnection(finished: true); }