Skip to content

Instantly share code, notes, and snippets.

@Toumash
Created November 24, 2019 18:07
Show Gist options
  • Save Toumash/9d28ae65044ff6e1ee00c3d82b55b909 to your computer and use it in GitHub Desktop.
Save Toumash/9d28ae65044ff6e1ee00c3d82b55b909 to your computer and use it in GitHub Desktop.
polly-example
var retryPolicy = Policy
.HandleResult<IRestResponse<RootObject>>(r => !r.IsSuccessful)
.Or<TimeoutRejectedException>()
.WaitAndRetryAsync(new[] { TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2)});
var response = await retryPolicy.ExecuteAsync(() =>
{
var client = new RestClient(\$"https://sample.api/api/search/nip/{line}?date=2019-11-15");
var request = new RestRequest(Method.GET);
return client.ExecuteTaskAsync<RootObject>(request);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment