Skip to main content

Overview

The Polly.Core namespace provides the foundational types for building and executing resilience pipelines in .NET applications.

Key Classes

ResilienceContext

A context assigned to a single execution of a ResiliencePipeline. It is created manually or automatically when executing resilience operations.
string?
A key unique to the call site of the current execution. This value should have low cardinality (do not use GUIDs).
CancellationToken
The cancellation token associated with the execution.
bool
Indicates whether the execution should continue on the captured context.
ResilienceProperties
Custom properties attached to the context.
Do not re-use an instance of ResilienceContext across more than one execution. Retrieve contexts from the pool using ResilienceContextPool.Get(CancellationToken) and return them with ResilienceContextPool.Return(ResilienceContext).

Outcome<TResult>

Represents the outcome of an operation, which can be either a result value or an exception. Used in advanced, low-allocation scenarios.

Static Factory Methods

Outcome<TResult>
Creates an outcome with the given result value.
Outcome<TResult>
Creates an outcome with the given exception.
ValueTask<Outcome<TResult>>
Returns an outcome with the given value wrapped as a completed ValueTask.
ValueTask<Outcome<TResult>>
Returns an outcome with the given exception wrapped as a completed ValueTask.

Example Usage