Table of Contents

Class ResilienceStrategy<TResult>

Namespace
Polly
Assembly
Polly.Core.dll

This base strategy class is used to simplify the implementation of generic (reactive) strategies by limiting the number of generic types the execute method receives.

public abstract class ResilienceStrategy<TResult>

Type Parameters

TResult

The type of result this strategy handles.

Inheritance
ResilienceStrategy<TResult>
Derived
Inherited Members

Remarks

For strategies that handle all result types the generic parameter must be of type object.

Methods

ExecuteCore<TState>(Func<ResilienceContext, TState, ValueTask<Outcome<TResult>>>, ResilienceContext, TState)

An implementation of a reactive resilience strategy that executes the specified callback.

protected abstract ValueTask<Outcome<TResult>> ExecuteCore<TState>(Func<ResilienceContext, TState, ValueTask<Outcome<TResult>>> callback, ResilienceContext context, TState state)

Parameters

callback Func<ResilienceContext, TState, ValueTask<Outcome<TResult>>>

The user-provided callback.

context ResilienceContext

The context associated with the callback.

state TState

The state associated with the callback.

Returns

ValueTask<Outcome<TResult>>

An instance of a pending ValueTask for asynchronous executions or a completed ValueTask task for synchronous executions.

Type Parameters

TState

The type of state associated with the callback.

Remarks

The provided callback never throws an exception. Instead, the exception is captured and converted to an Outcome<TResult>. Similarly, do not throw exceptions from your strategy implementation. Instead, return an exception instance as Outcome<TResult>.