My previous blog post gave a very short description of Polly and that we were going to use it at work. The Polly library expose a set of options how to make your software more resilient. The most common (my guess) is a simple retry functionality, retry calling e.g. the database x number of times (x can also be indefinitely). Other options are timeouts, cache functionality, fallbacks and a couple more. Our demand, however, didn’t exactly fit into the retry policy of Polly. We wanted to try x number of times (e.g. five times with two seconds of sleep between tries), then sleep for some time (e.g. 30 or 60 seconds) and then try again five times. Repeat until success. Also, we only wanted to log first time there is an error, and then when the try was successful (after retries, not if successful on first attempt). using System; using Microsoft.Extensions.Logging; using Polly; using Polly.Retry; namespace R...
A blog about software development and architecture. The main focus is .NET and Open Source.