Class ResilienceStrategy
- Namespace
- Polly
- Assembly
- Polly.Core.dll
Base class for all proactive resilience strategies.
public abstract class ResilienceStrategy
- Inheritance
-
ResilienceStrategy
- Inherited Members
Methods
ExecuteCore<TResult, TState>(Func<ResilienceContext, TState, ValueTask<Outcome<TResult>>>, ResilienceContext, TState)
An implementation of a proactive resilience strategy that executes the specified callback.
protected abstract ValueTask<Outcome<TResult>> ExecuteCore<TResult, TState>(Func<ResilienceContext, TState, ValueTask<Outcome<TResult>>> callback, ResilienceContext context, TState state)
Parameters
callbackFunc<ResilienceContext, TState, ValueTask<Outcome<TResult>>>The user-provided callback.
contextResilienceContextThe context associated with the callback.
stateTStateThe 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
TResultThe type of result returned by the callback.
TStateThe 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>.