DEV Community

How we Added Auto-Retries to our C# API Client

Roger Jin on April 18, 2017

For more content like this, follow ButterCMS on Twitter and subscribe to our blog. Networks are unreliable. At some point we’ve all experienced ...
Collapse
 
manigandham profile image
Mani Gandham

LINQ uses lazy evaluation so uniqueExceptions in the last example will be enumerated and processed for distinct elements 3 times - for the .Count(), .First() and the final return. You should just call .ToList() after .Distinct() to get an actual List of exceptions.

There's also the Polly library which handles retries, timeouts, circuit breakers and many other resiliency situations in a well built API.

github.com/App-vNext/Polly

Collapse
 
programatt profile image
Matt Phillips

Nice article. I've been looking at some of the concepts in Netflix's OSS client library hystrix github.com/Netflix/Hystrix for my api clients. It's got other useful functions like circuit breakers and incremental backoff on retries. There's even a c# port of it. github.com/Elders/Hystrix.NET