private string Get(string uri)
 {
     try
     {
         return(callStrategy.Call(
                    () =>
         {
             var httpResponseMessage = httpClient.GetAsync($"{apiPrefix}{uri}").GetAwaiter().GetResult();
             if (!httpResponseMessage.IsSuccessStatusCode)
             {
                 throw new HttpListenerException((int)httpResponseMessage.StatusCode, httpResponseMessage.ReasonPhrase);
             }
             return httpResponseMessage.Content.ReadAsStringAsync().GetAwaiter().GetResult();
         }, IsExceptionRetriable, log));
     }
     catch (Exception ex)
     {
         throw new Exception("Could not get data by URL " + uri, ex);
     }
 }
Example #2
0
 public void SendPacket(JsonPacket packet, ICounter sendingErrorCounter)
 {
     retriableCallStrategy.Call(() =>
     {
         var requester = new Requester(packet, ravenClient);
         return(requester.Request());
     }, e =>
     {
         sendingErrorCounter.Add();
         return(IsRetriableException(e));
     }, log);
 }