explaingit

app-vnext/polly

14,164C#Audience · developerComplexity · 2/5Setup · easy

TLDR

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.

Mindmap

mindmap
  root((Polly))
    What it does
      Resilience policies
      Failure handling
      Retry logic
    Strategies
      Retry
      Circuit Breaker
      Timeout
      Rate Limiter
    Tech Stack
      C# and .NET
      NuGet package
    Audience
      .NET developers
      Backend engineers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Wrap an HTTP client so it automatically retries failed requests up to three times with an exponential backoff delay.

USE CASE 2

Add a circuit breaker to database calls so a struggling service is not overwhelmed with repeated requests.

USE CASE 3

Set a hard timeout on any slow operation and define a fallback value to return when it times out.

USE CASE 4

Limit how many requests your app sends to a third-party API per minute using a rate limiter policy.

Tech stack

C#.NETNuGet

Getting it running

Difficulty · easy Time to first run · 30min

The v8 API is a breaking change from v7, check the migration guide if upgrading from an older Polly version.

License not specified in the repository description.

In plain English

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.

Copy-paste prompts

Prompt 1
Using Polly v8 in C#, show me how to build a resilience pipeline that retries an HTTP request 3 times with exponential backoff and then opens a circuit breaker after 5 consecutive failures.
Prompt 2
I have a slow database call in my .NET app. Show me how to wrap it with Polly to add a 2-second timeout and a fallback that returns a cached result when it expires.
Prompt 3
How do I register a Polly resilience pipeline in a .NET dependency injection container and inject it into a service class?
Prompt 4
Show me how to use Polly's Hedging strategy to send two copies of a request in parallel and return whichever completes first.
Prompt 5
I want to write a unit test for code that uses a Polly pipeline. Show me how to use Polly's testing helper to simulate a retry or circuit breaker triggering.
Open on GitHub → Explain another repo

← app-vnext on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.