Table of Contents

Struct HedgingActionGeneratorArguments<TResult>

Namespace
Polly.Hedging
Assembly
Polly.Core.dll

Represents arguments used in the hedging resilience strategy.

public readonly struct HedgingActionGeneratorArguments<TResult>

Type Parameters

TResult

The type of the result.

Inherited Members

Remarks

The PrimaryContext represents the context that was received by the hedging strategy and used to execute the primary action. To prevent race conditions, the hedging strategy then clones the primary context into ActionContext and uses it to execute the hedged action. Every hedged action gets its own context that is cloned from the primary.

Always use the constructor when creating this struct, otherwise we do not guarantee binary compatibility.

Constructors

HedgingActionGeneratorArguments(ResilienceContext, ResilienceContext, int, Func<ResilienceContext, ValueTask<Outcome<TResult>>>)

Initializes a new instance of the HedgingActionGeneratorArguments<TResult> struct.

public HedgingActionGeneratorArguments(ResilienceContext primaryContext, ResilienceContext actionContext, int attemptNumber, Func<ResilienceContext, ValueTask<Outcome<TResult>>> callback)

Parameters

primaryContext ResilienceContext

The primary context received by the hedging strategy.

actionContext ResilienceContext

The action context cloned from the primary context.

attemptNumber int

The zero-based hedging attempt number.

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

The callback passed to the hedging strategy.

Properties

ActionContext

Gets the action context that will be used for the hedged action.

public ResilienceContext ActionContext { get; }

Property Value

ResilienceContext

Remarks

This context is cloned from PrimaryContext.

AttemptNumber

Gets the zero-based hedging attempt number.

public int AttemptNumber { get; }

Property Value

int

Callback

Gets the callback passed to the hedging strategy.

public Func<ResilienceContext, ValueTask<Outcome<TResult>>> Callback { get; }

Property Value

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

PrimaryContext

Gets the primary resilience context as received by the hedging strategy.

public ResilienceContext PrimaryContext { get; }

Property Value

ResilienceContext