예제 #1
0
        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));
                }
            }
        }
예제 #2
0
 public void SetUp()
 {
     _webClientFactory = Substitute.For <IWebClientFactory>();
     _target           = new BulkSender(_webClientFactory, Substitute.For <IInternalLogger>());
     _webClient        = Substitute.For <IWebClient>();
     _webClientFactory.GetWebClient().Returns(x => _webClient);
 }
예제 #3
0
        public BuildDataFetcher(CruiseAddress cruiseAddress, IConfigSettings configSettings,
		                        IWebClientFactory webClientFactory)
        {
            _cruiseAddress = cruiseAddress;
            _webClientFactory = webClientFactory;
            _webClient = webClientFactory.GetWebClient(configSettings.URL);
            configSettings.AddObserver(this);
        }
예제 #4
0
 public BuildDataFetcher(ViewUrl viewUrl, IConfigSettings configSettings,
                         IWebClientFactory webClientFactory)
 {
     _viewUrl          = viewUrl;
     _webClientFactory = webClientFactory;
     _webClient        = webClientFactory.GetWebClient(configSettings.URL);
     configSettings.AddObserver(this);
 }
예제 #5
0
        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));
            }
        }
예제 #7
0
 public void ConfigUpdated(ConfigSettings newSettings)
 {
     _viewUrl.Url = newSettings.URL;
     _webClient   = _webClientFactory.GetWebClient(newSettings.URL);
 }
예제 #8
0
 public BuildDataFetcher(ViewUrl viewUrl, string url, IWebClientFactory webClientFactory)
 {
     _viewUrl = viewUrl;
     _webClient = webClientFactory.GetWebClient(url);
 }