ResilienceStrategy<T>
Resilience strategy is used to execute the user-provided callbacks.
using Polly.Utils;
using System;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
namespace Polly
{
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(0)]
public class ResilienceStrategy<[System.Runtime.CompilerServices.Nullable(2)] T>
{
internal ResilienceStrategy Strategy { get; }
internal ResilienceStrategy(ResilienceStrategy strategy)
{
Strategy = strategy;
}
[return: System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1
})]
public ValueTask<TResult> ExecuteAsync<[System.Runtime.CompilerServices.Nullable(0)] TResult, [System.Runtime.CompilerServices.Nullable(2)] TState>([System.Runtime.CompilerServices.Nullable(new byte[] {
1,
1,
1,
0,
1
})] Func<ResilienceContext, TState, ValueTask<TResult>> callback, ResilienceContext context, TState state) where TResult : T
{
Guard.NotNull<Func<ResilienceContext, TState, ValueTask<TResult>>>(callback, "callback");
Guard.NotNull<ResilienceContext>(context, "context");
return this.Strategy.ExecuteAsync<TResult, TState>(callback, context, state);
}
[return: System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1
})]
public ValueTask<TResult> ExecuteAsync<[System.Runtime.CompilerServices.Nullable(0)] TResult>([System.Runtime.CompilerServices.Nullable(new byte[] {
1,
1,
0,
1
})] Func<ResilienceContext, ValueTask<TResult>> callback, ResilienceContext context) where TResult : T
{
Guard.NotNull<Func<ResilienceContext, ValueTask<TResult>>>(callback, "callback");
Guard.NotNull<ResilienceContext>(context, "context");
return this.Strategy.ExecuteAsync<TResult>(callback, context);
}
[return: System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1
})]
public ValueTask<TResult> ExecuteAsync<[System.Runtime.CompilerServices.Nullable(0)] TResult, [System.Runtime.CompilerServices.Nullable(2)] TState>([System.Runtime.CompilerServices.Nullable(new byte[] {
1,
1,
0,
1
})] Func<TState, CancellationToken, ValueTask<TResult>> callback, TState state, CancellationToken cancellationToken = default(CancellationToken)) where TResult : T
{
Guard.NotNull<Func<TState, CancellationToken, ValueTask<TResult>>>(callback, "callback");
return this.Strategy.ExecuteAsync<TResult, TState>(callback, state, cancellationToken);
}
[System.Runtime.CompilerServices.NullableContext(2)]
[return: System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1
})]
public ValueTask<TResult> ExecuteAsync<TResult>([System.Runtime.CompilerServices.Nullable(new byte[] {
1,
0,
1
})] Func<CancellationToken, ValueTask<TResult>> callback, CancellationToken cancellationToken = default(CancellationToken))
{
Guard.NotNull<Func<CancellationToken, ValueTask<TResult>>>(callback, "callback");
return this.Strategy.ExecuteAsync<TResult>(callback, cancellationToken);
}
[return: System.Runtime.CompilerServices.Nullable(new byte[] {
0,
0,
1
})]
public ValueTask<Outcome<TResult>> ExecuteOutcomeAsync<[System.Runtime.CompilerServices.Nullable(0)] TResult, [System.Runtime.CompilerServices.Nullable(2)] TState>([System.Runtime.CompilerServices.Nullable(new byte[] {
1,
1,
1,
0,
0,
1
})] Func<ResilienceContext, TState, ValueTask<Outcome<TResult>>> callback, ResilienceContext context, TState state) where TResult : T
{
Guard.NotNull<Func<ResilienceContext, TState, ValueTask<Outcome<TResult>>>>(callback, "callback");
Guard.NotNull<ResilienceContext>(context, "context");
return this.Strategy.ExecuteOutcomeAsync<TResult, TState>(callback, context, state);
}
public TResult Execute<[System.Runtime.CompilerServices.Nullable(0)] TResult, [System.Runtime.CompilerServices.Nullable(2)] TState>(Func<ResilienceContext, TState, TResult> callback, ResilienceContext context, TState state) where TResult : T
{
Guard.NotNull<Func<ResilienceContext, TState, TResult>>(callback, "callback");
Guard.NotNull<ResilienceContext>(context, "context");
return this.Strategy.Execute<TResult, TState>(callback, context, state);
}
public TResult Execute<[System.Runtime.CompilerServices.Nullable(0)] TResult>(Func<ResilienceContext, TResult> callback, ResilienceContext context) where TResult : T
{
Guard.NotNull<Func<ResilienceContext, TResult>>(callback, "callback");
Guard.NotNull<ResilienceContext>(context, "context");
return this.Strategy.Execute<TResult>(callback, context);
}
public TResult Execute<[System.Runtime.CompilerServices.Nullable(0)] TResult>(Func<CancellationToken, TResult> callback, CancellationToken cancellationToken = default(CancellationToken)) where TResult : T
{
Guard.NotNull<Func<CancellationToken, TResult>>(callback, "callback");
return this.Strategy.Execute<TResult>(callback, cancellationToken);
}
public TResult Execute<[System.Runtime.CompilerServices.Nullable(0)] TResult>(Func<TResult> callback) where TResult : T
{
Guard.NotNull<Func<TResult>>(callback, "callback");
return this.Strategy.Execute<TResult>(callback);
}
public TResult Execute<[System.Runtime.CompilerServices.Nullable(0)] TResult, [System.Runtime.CompilerServices.Nullable(2)] TState>(Func<TState, TResult> callback, TState state) where TResult : T
{
Guard.NotNull<Func<TState, TResult>>(callback, "callback");
return this.Strategy.Execute<TResult, TState>(callback, state);
}
public TResult Execute<[System.Runtime.CompilerServices.Nullable(0)] TResult, [System.Runtime.CompilerServices.Nullable(2)] TState>(Func<TState, CancellationToken, TResult> callback, TState state, CancellationToken cancellationToken = default(CancellationToken)) where TResult : T
{
Guard.NotNull<Func<TState, CancellationToken, TResult>>(callback, "callback");
return this.Strategy.Execute<TResult, TState>(callback, state, cancellationToken);
}
}
}