Fault tolerance with Polly
Polly is “a .NET resilience and transient-fault-handling library that allows developers to express policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, and Fallback in a fluent and thread-safe manner,” as stated on the official Polly GitHub repository, which can be found at the following link: https://github.com/App-vNext/Polly.
Transient faults are errors caused by temporary conditions, such as temporary service unavailability or network connectivity issues. It is essential to handle transient faults in distributed systems, or they can become almost unusable.
Understanding retry and circuit breaker patterns
The Retry pattern enables clients to automatically retry a failed action with the expectation that the fault will succeed if retried after a short delay. Be careful, because if you implement the Retry pattern naively, then it can make the problem worse!
For example, if you set a fixed time between retries...