gitmyhub

Polly

C# ★ 14k updated 1d ago

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. From version 6.0.1, Polly targets .NET Standard 1.1 and 2.0+.

Polly is a .NET C# library that wraps any code with resilience behaviors, automatic retries, circuit breakers, timeouts, and rate limiters, so your app handles failures gracefully without extra boilerplate.

C#.NETNuGetsetup: easycomplexity 2/5

Polly is a .NET library that helps applications handle failures gracefully when making calls to external services, databases, or any operation that might fail or be slow. It is written for the C# ecosystem and is installed as a NuGet package.

The library centers on a concept called resilience strategies: named patterns for dealing with failure. Retry automatically repeats a failing operation a configurable number of times, with optional delays between attempts. Circuit Breaker stops all attempts for a period when failures exceed a threshold, which protects an already-struggling service from being overwhelmed further. Timeout sets a maximum time an operation can take before it is abandoned. Rate Limiter controls how many calls can go out in a given window. Fallback defines what to return or do when all else fails. Hedging runs multiple copies of a request in parallel and takes the first one that succeeds.

These strategies are combined into a resilience pipeline: a chain of behaviors that wrap any code you want to run. You configure the pipeline once, then execute your logic through it. Polly handles applying all the configured strategies in sequence.

The library supports modern .NET patterns including dependency injection, async/await, and integration with telemetry tools. The v8 API introduced with recent releases restructured the interface compared to older versions; there is a legacy package for applications still on the v7 interface.

Polly is a member of the .NET Foundation, which indicates it has institutional backing for long-term maintenance. The repository includes packages for the core library, extensions for dependency injection and telemetry, rate-limiting integration, and a testing helper for writing unit tests against code that uses resilience pipelines.

Where it fits