<PackageReference Include="Polly.Core" Version="8.6.4" />

HedgingStrategyOptions<TResult>

Hedging strategy options.
using Polly.Utils; using System; using System.ComponentModel.DataAnnotations; using System.Runtime.CompilerServices; using System.Threading.Tasks; namespace Polly.Hedging { public class HedgingStrategyOptions<[Nullable(2)] TResult> : ResilienceStrategyOptions { [Nullable(new byte[] { 1, 0, 1, 2, 0, 0, 1 })] internal static readonly Func<HedgingActionGeneratorArguments<TResult>, Func<ValueTask<Outcome<TResult>>>> DefaultActionGenerator = (HedgingActionGeneratorArguments<TResult> args) => delegate { if (args.PrimaryContext.IsSynchronous) return new ValueTask<Outcome<TResult>>(Task.Run<Outcome<TResult>>((Func<Task<Outcome<TResult>>>)(() => args.Callback(args.ActionContext).AsTask()))); return args.Callback(args.ActionContext); }; public TimeSpan Delay { get; set; } = HedgingConstants.DefaultHedgingDelay; [Range(1, 10)] public int MaxHedgedAttempts { get; set; } = 1; [Nullable(new byte[] { 1, 0, 1, 0 })] [Required] [field: Nullable(new byte[] { 1, 0, 1, 0 })] public Func<HedgingPredicateArguments<TResult>, ValueTask<bool>> ShouldHandle { [return: Nullable(new byte[] { 1, 0, 1, 0 })] get; [param: Nullable(new byte[] { 1, 0, 1, 0 })] set; } = DefaultPredicates<HedgingPredicateArguments<TResult>, TResult>.HandleOutcome; [Nullable(new byte[] { 1, 0, 1, 2, 0, 0, 1 })] [Required] [field: Nullable(new byte[] { 1, 0, 1, 2, 0, 0, 1 })] public Func<HedgingActionGeneratorArguments<TResult>, Func<ValueTask<Outcome<TResult>>>> ActionGenerator { [return: Nullable(new byte[] { 1, 0, 1, 2, 0, 0, 1 })] get; [param: Nullable(new byte[] { 1, 0, 1, 2, 0, 0, 1 })] set; } = DefaultActionGenerator; [Nullable(new byte[] { 2, 0 })] [field: Nullable(new byte[] { 2, 0 })] public Func<HedgingDelayGeneratorArguments, ValueTask<TimeSpan>> DelayGenerator { [return: Nullable(new byte[] { 2, 0 })] get; [param: Nullable(new byte[] { 2, 0 })] set; } [Nullable(new byte[] { 2, 0, 1 })] [field: Nullable(new byte[] { 2, 0, 1 })] public Func<OnHedgingArguments<TResult>, ValueTask> OnHedging { [return: Nullable(new byte[] { 2, 0, 1 })] get; [param: Nullable(new byte[] { 2, 0, 1 })] set; } public HedgingStrategyOptions() { base.Name = "Hedging"; } } }