C# – How to use Polly to do retries

Whenever you’re dealing with code that can run into transient errors, it’s a good idea to implement retries. Transient errors, by definition, are temporary and subsequent attempts should succeed. When you retry with a delay, it means you think the the transient error will go away by itself after a short period of time. When … Read more

How to do retries in EF Core

EF Core has built-in retry functionality. To use it, you can call options.EnableRetryOnFailure(), like this: The retry logic is contained in execution strategy classes. The above code is using the default execution strategy class (SqlServerRetryingExecutionStrategy). When you execute a query, it goes through the execution strategy class. It executes the query and checks for transient … Read more

How to use toxiproxy to verify your code can handle timeouts and unavailable endpoints

When you have code that calls an endpoint, you need to make sure it’s resilient and can handle error scenarios, such as timeouts. One way to prove your code is resilient is by using toxiproxy to simulate bad behavior. Toxiproxy sits between your client code and the endpoint. It receives requests from your client, applies … Read more