Though Polly provides it out-of-the-box with reasonable defaults, you don't need 3rd party libraries to reuse retry logic with HttpClient.
Just extract it to DelegatingHandler
publicclassRetryHandler:DelegatingHandler{protectedoverrideasyncTask<HttpResponseMessage>SendAsync(HttpRequestMessagerequest,CancellationTokencancellationToken){/* your retry logic ... */}}
One advantage with Polly is that you can also enable ChaosMonkey (Simmy in Polly terms). I do this for all Polly policies and activate it for development only. Great way to test your resilience.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Though Polly provides it out-of-the-box with reasonable defaults, you don't need 3rd party libraries to reuse retry logic with HttpClient.
Just extract it to DelegatingHandler
and then add it to DI:
Hi Dmitry,
Thank you very much for your comment, it is a very nice addition to the post.
It is always nice to have more options on the table!
One advantage with Polly is that you can also enable ChaosMonkey (Simmy in Polly terms). I do this for all Polly policies and activate it for development only. Great way to test your resilience.