Created
November 24, 2019 18:07
-
-
Save Toumash/9d28ae65044ff6e1ee00c3d82b55b909 to your computer and use it in GitHub Desktop.
polly-example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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