public void Send(ICollection <LogzioLoggingEvent> logz, BulkSenderOptions options, int attempt = 0) { if (logz == null || logz.Count == 0) { return; } var url = string.Format(UrlTemplate, options.ListenerUrl, options.Token, options.Type); try { using (var client = _webClientFactory.GetWebClient()) { var serializedLogLines = logz.Select(x => Serialize(x.LogData)).ToArray(); var body = String.Join(Environment.NewLine, serializedLogLines); client.UploadString(url, body); if (options.Debug) { _internalLogger.Log("Sent bulk of [{0}] log messages to [{1}] successfully.", logz.Count, url); } } } catch (Exception ex) { if (options.Debug) { _internalLogger.Log("Logzio.DotNet ERROR: " + ex); } if (attempt < options.RetriesMaxAttempts - 1) { Task.Delay(options.RetriesInterval).ContinueWith(task => Send(logz, options, attempt + 1)); } } }
public void SetUp() { _webClientFactory = Substitute.For <IWebClientFactory>(); _target = new BulkSender(_webClientFactory, Substitute.For <IInternalLogger>()); _webClient = Substitute.For <IWebClient>(); _webClientFactory.GetWebClient().Returns(x => _webClient); }
public BuildDataFetcher(CruiseAddress cruiseAddress, IConfigSettings configSettings, IWebClientFactory webClientFactory) { _cruiseAddress = cruiseAddress; _webClientFactory = webClientFactory; _webClient = webClientFactory.GetWebClient(configSettings.URL); configSettings.AddObserver(this); }
public BuildDataFetcher(ViewUrl viewUrl, IConfigSettings configSettings, IWebClientFactory webClientFactory) { _viewUrl = viewUrl; _webClientFactory = webClientFactory; _webClient = webClientFactory.GetWebClient(configSettings.URL); configSettings.AddObserver(this); }
public string Resolve(Uri endpoint, string method, WebHeaderCollection headers) { using (var webClientWrapper = _webClientFactory.GetWebClient()) { webClientWrapper.Encoding = Encoding.UTF8; webClientWrapper.Headers.Add(headers); return(webClientWrapper.UploadString(endpoint.AbsoluteUri, method, ParametersAsString)); } }
public void ConfigUpdated(ConfigSettings newSettings) { _viewUrl.Url = newSettings.URL; _webClient = _webClientFactory.GetWebClient(newSettings.URL); }
public BuildDataFetcher(ViewUrl viewUrl, string url, IWebClientFactory webClientFactory) { _viewUrl = viewUrl; _webClient = webClientFactory.GetWebClient(url); }