How to use Polly, Refit and .Net 5

Bernardo Teixeira
Geek Culture
Published in
3 min readOct 4, 2021

--

Photo by Markus Spiske on Unsplash

Polly allows you to make your project more reliable, less fragile, and fault-tolerant. Polly creates an abstraction so you can use Retry Pattern and Break Circuit Pattern without any concerns or implications. The Refit, make HTTP Clients and API connection.

How this will work

I created two projects, the API project, which is a standard and simple Web Application so that I can get the data, and the Client project is a Console Application.

Top View

Low View

The Patterns

Retry Pattern

The retry pattern is an extremely important pattern to make applications and services more resilient to transient failures. A transient failure is a common type of failure in a cloud-based distributed architecture. This is often due to the nature of the network itself (loss of connectivity, timeout on requests, and so on). Transient faults occur when services are hosted separately and communicate over the wire, most likely over a HTTP protocol. These faults are expected to be short-lived. Repeating such a request that has previously failed could…

--

--