RetryContext Struct

Namespace
Kampute.Resilience
Assembly
  • Kampute.Resilience.dll

Definition

Describes a failed attempt and the delay before the operation is retried.
public readonly struct RetryContext
Inheritance

Remarks

RetryPolicy passes this value to its delay override and retry handlers. It is a value type, so describing a retry allocates nothing. A policy that retries only exceptions always supplies an Exception; a RetryPolicy<T> converts its RetryContext<T> to this type for handlers registered before it became result-aware, and then Exception is null for a retried result.

Properties

AttemptNumber

Gets the number of the attempt that failed.
public uint AttemptNumber { get; }

Property Value

uint
A one-based number within this execution; the initial attempt is 1. It is also the number of retries made once this retry starts.

Delay

Gets the delay before the next attempt.
public TimeSpan Delay { get; }

Property Value

TimeSpan
In a delay override, the delay that the strategy proposes; in a retry handler, the delay that execution waits.

Elapsed

Gets the time since execution started when the outcome of the attempt was evaluated.
public TimeSpan Elapsed { get; }

Property Value

TimeSpan
The elapsed execution time, including earlier attempts and waits.

Exception

Gets the exception thrown by the attempt.
public Exception Exception { get; }

Property Value

Exception
The original exception, or null when a RetryPolicy<T> retries a returned result.