RetryContext<T> Struct
- Namespace
- Kampute.Resilience
- Assembly
- Kampute.Resilience.dll
Definition
Describes a failed attempt of an operation that returns a value, and the delay before the operation is retried.
public readonly struct RetryContext<T>Type Parameters
T- The type returned by the operation.
Remarks
RetryPolicy<T> passes this value to its delay override and retry handlers. An attempt fails either by throwing an exception that the policy retries or by returning a result that the policy retries; HasResult tells them apart.
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
HasResult
Gets whether the attempt returned a result rather than throwing an exception.
public bool HasResult { get; }Property Value
Result
Gets the value returned by the attempt.
public T Result { get; }Property Value
Operators
Implicit(RetryContext<T>)
Converts a context to the form that does not carry the result.
public static implicit operator RetryContext(RetryContext<T> context)Parameters
contextRetryContext<T>- The context to convert.
Returns
- RetryContext
- A RetryContext with the same attempt number, elapsed time, exception, and delay.
