Class RetryTResultSyntax
- Namespace
- Polly
- Assembly
- Polly.dll
Fluent API for defining a Retry Policy.
public static class RetryTResultSyntax
- Inheritance
-
RetryTResultSyntax
- Inherited Members
Methods
RetryForever<TResult>(PolicyBuilder<TResult>)
Builds a Policy that will retry indefinitely until the action succeeds.
public static RetryPolicy<TResult> RetryForever<TResult>(this PolicyBuilder<TResult> policyBuilder)
Parameters
policyBuilder
PolicyBuilder<TResult>The policy builder.
Returns
- RetryPolicy<TResult>
The policy instance.
Type Parameters
TResult
RetryForever<TResult>(PolicyBuilder<TResult>, Action<DelegateResult<TResult>, Context>)
Builds a Policy that will retry indefinitely
calling onRetry
on each retry with the handled exception or result and context data.
public static RetryPolicy<TResult> RetryForever<TResult>(this PolicyBuilder<TResult> policyBuilder, Action<DelegateResult<TResult>, Context> onRetry)
Parameters
policyBuilder
PolicyBuilder<TResult>The policy builder.
onRetry
Action<DelegateResult<TResult>, Context>The action to call on each retry.
Returns
- RetryPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
onRetry
RetryForever<TResult>(PolicyBuilder<TResult>, Action<DelegateResult<TResult>>)
Builds a Policy that will retry indefinitely
calling onRetry
on each retry with the handled exception or result.
public static RetryPolicy<TResult> RetryForever<TResult>(this PolicyBuilder<TResult> policyBuilder, Action<DelegateResult<TResult>> onRetry)
Parameters
policyBuilder
PolicyBuilder<TResult>The policy builder.
onRetry
Action<DelegateResult<TResult>>The action to call on each retry.
Returns
- RetryPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
onRetry
Retry<TResult>(PolicyBuilder<TResult>)
Builds a Policy that will retry once.
public static RetryPolicy<TResult> Retry<TResult>(this PolicyBuilder<TResult> policyBuilder)
Parameters
policyBuilder
PolicyBuilder<TResult>The policy builder.
Returns
- RetryPolicy<TResult>
The policy instance.
Type Parameters
TResult
Retry<TResult>(PolicyBuilder<TResult>, Action<DelegateResult<TResult>, int, Context>)
Builds a Policy that will retry once
calling onRetry
on retry with the handled exception or result, retry count and context data.
public static RetryPolicy<TResult> Retry<TResult>(this PolicyBuilder<TResult> policyBuilder, Action<DelegateResult<TResult>, int, Context> onRetry)
Parameters
policyBuilder
PolicyBuilder<TResult>The policy builder.
onRetry
Action<DelegateResult<TResult>, int, Context>The action to call on each retry.
Returns
- RetryPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
onRetry
Retry<TResult>(PolicyBuilder<TResult>, Action<DelegateResult<TResult>, int>)
Builds a Policy that will retry once
calling onRetry
on retry with the handled exception or result and retry count.
public static RetryPolicy<TResult> Retry<TResult>(this PolicyBuilder<TResult> policyBuilder, Action<DelegateResult<TResult>, int> onRetry)
Parameters
policyBuilder
PolicyBuilder<TResult>The policy builder.
onRetry
Action<DelegateResult<TResult>, int>The action to call on each retry.
Returns
- RetryPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
onRetry
Retry<TResult>(PolicyBuilder<TResult>, int)
Builds a Policy that will retry retryCount
times.
public static RetryPolicy<TResult> Retry<TResult>(this PolicyBuilder<TResult> policyBuilder, int retryCount)
Parameters
policyBuilder
PolicyBuilder<TResult>The policy builder.
retryCount
intThe retry count.
Returns
- RetryPolicy<TResult>
The policy instance.
Type Parameters
TResult
Retry<TResult>(PolicyBuilder<TResult>, int, Action<DelegateResult<TResult>, int, Context>)
Builds a Policy that will retry retryCount
times
calling onRetry
on each retry with the handled exception or result, retry count and context data.
public static RetryPolicy<TResult> Retry<TResult>(this PolicyBuilder<TResult> policyBuilder, int retryCount, Action<DelegateResult<TResult>, int, Context> onRetry)
Parameters
policyBuilder
PolicyBuilder<TResult>The policy builder.
retryCount
intThe retry count.
onRetry
Action<DelegateResult<TResult>, int, Context>The action to call on each retry.
Returns
- RetryPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentOutOfRangeException
retryCount;Value must be greater than or equal to zero.
- ArgumentNullException
onRetry
Retry<TResult>(PolicyBuilder<TResult>, int, Action<DelegateResult<TResult>, int>)
Builds a Policy that will retry retryCount
times
calling onRetry
on each retry with the handled exception or result and retry count.
public static RetryPolicy<TResult> Retry<TResult>(this PolicyBuilder<TResult> policyBuilder, int retryCount, Action<DelegateResult<TResult>, int> onRetry)
Parameters
policyBuilder
PolicyBuilder<TResult>The policy builder.
retryCount
intThe retry count.
onRetry
Action<DelegateResult<TResult>, int>The action to call on each retry.
Returns
- RetryPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentOutOfRangeException
retryCount;Value must be greater than or equal to zero.
- ArgumentNullException
onRetry
WaitAndRetryForever<TResult>(PolicyBuilder<TResult>, Func<int, Context, TimeSpan>)
Builds a Policy that will wait and retry indefinitely until the action succeeds.
public static RetryPolicy<TResult> WaitAndRetryForever<TResult>(this PolicyBuilder<TResult> policyBuilder, Func<int, Context, TimeSpan> sleepDurationProvider)
Parameters
policyBuilder
PolicyBuilder<TResult>The policy builder.
sleepDurationProvider
Func<int, Context, TimeSpan>The function that provides the duration to wait for for a particular retry attempt.
Returns
- RetryPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
sleepDurationProvider
WaitAndRetryForever<TResult>(PolicyBuilder<TResult>, Func<int, Context, TimeSpan>, Action<DelegateResult<TResult>, TimeSpan, Context>)
Builds a Policy that will wait and retry indefinitely until the action succeeds,
calling onRetry
on each retry with the handled exception or result and
execution context.
public static RetryPolicy<TResult> WaitAndRetryForever<TResult>(this PolicyBuilder<TResult> policyBuilder, Func<int, Context, TimeSpan> sleepDurationProvider, Action<DelegateResult<TResult>, TimeSpan, Context> onRetry)
Parameters
policyBuilder
PolicyBuilder<TResult>The policy builder.
sleepDurationProvider
Func<int, Context, TimeSpan>A function providing the duration to wait before retrying.
onRetry
Action<DelegateResult<TResult>, TimeSpan, Context>The action to call on each retry.
Returns
- RetryPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
sleepDurationProvider
- ArgumentNullException
onRetry
WaitAndRetryForever<TResult>(PolicyBuilder<TResult>, Func<int, TimeSpan>)
Builds a Policy that will wait and retry indefinitely until the action succeeds.
public static RetryPolicy<TResult> WaitAndRetryForever<TResult>(this PolicyBuilder<TResult> policyBuilder, Func<int, TimeSpan> sleepDurationProvider)
Parameters
policyBuilder
PolicyBuilder<TResult>The policy builder.
sleepDurationProvider
Func<int, TimeSpan>The function that provides the duration to wait for for a particular retry attempt.
Returns
- RetryPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
sleepDurationProvider
WaitAndRetryForever<TResult>(PolicyBuilder<TResult>, Func<int, TimeSpan>, Action<DelegateResult<TResult>, TimeSpan>)
Builds a Policy that will wait and retry indefinitely until the action succeeds,
calling onRetry
on each retry with the handled exception or result.
public static RetryPolicy<TResult> WaitAndRetryForever<TResult>(this PolicyBuilder<TResult> policyBuilder, Func<int, TimeSpan> sleepDurationProvider, Action<DelegateResult<TResult>, TimeSpan> onRetry)
Parameters
policyBuilder
PolicyBuilder<TResult>The policy builder.
sleepDurationProvider
Func<int, TimeSpan>A function providing the duration to wait before retrying.
onRetry
Action<DelegateResult<TResult>, TimeSpan>The action to call on each retry.
Returns
- RetryPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
sleepDurationProvider
- ArgumentNullException
onRetry
WaitAndRetry<TResult>(PolicyBuilder<TResult>, IEnumerable<TimeSpan>)
Builds a Policy that will wait and retry as many times as there are provided sleepDurations
On each retry, the duration to wait is the current sleepDurations
item.
public static RetryPolicy<TResult> WaitAndRetry<TResult>(this PolicyBuilder<TResult> policyBuilder, IEnumerable<TimeSpan> sleepDurations)
Parameters
policyBuilder
PolicyBuilder<TResult>The policy builder.
sleepDurations
IEnumerable<TimeSpan>The sleep durations to wait for on each retry.
Returns
- RetryPolicy<TResult>
The policy instance.
Type Parameters
TResult
WaitAndRetry<TResult>(PolicyBuilder<TResult>, IEnumerable<TimeSpan>, Action<DelegateResult<TResult>, TimeSpan, Context>)
Builds a Policy that will wait and retry as many times as there are provided sleepDurations
calling onRetry
on each retry with the handled exception or result, current sleep duration and context data.
On each retry, the duration to wait is the current sleepDurations
item.
public static RetryPolicy<TResult> WaitAndRetry<TResult>(this PolicyBuilder<TResult> policyBuilder, IEnumerable<TimeSpan> sleepDurations, Action<DelegateResult<TResult>, TimeSpan, Context> onRetry)
Parameters
policyBuilder
PolicyBuilder<TResult>The policy builder.
sleepDurations
IEnumerable<TimeSpan>The sleep durations to wait for on each retry.
onRetry
Action<DelegateResult<TResult>, TimeSpan, Context>The action to call on each retry.
Returns
- RetryPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
sleepDurations or onRetry
WaitAndRetry<TResult>(PolicyBuilder<TResult>, IEnumerable<TimeSpan>, Action<DelegateResult<TResult>, TimeSpan, int, Context>)
Builds a Policy that will wait and retry as many times as there are provided sleepDurations
calling onRetry
on each retry with the handled exception or result, current sleep duration, retry count and context data.
On each retry, the duration to wait is the current sleepDurations
item.
public static RetryPolicy<TResult> WaitAndRetry<TResult>(this PolicyBuilder<TResult> policyBuilder, IEnumerable<TimeSpan> sleepDurations, Action<DelegateResult<TResult>, TimeSpan, int, Context> onRetry)
Parameters
policyBuilder
PolicyBuilder<TResult>The policy builder.
sleepDurations
IEnumerable<TimeSpan>The sleep durations to wait for on each retry.
onRetry
Action<DelegateResult<TResult>, TimeSpan, int, Context>The action to call on each retry.
Returns
- RetryPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
sleepDurations or onRetry
WaitAndRetry<TResult>(PolicyBuilder<TResult>, IEnumerable<TimeSpan>, Action<DelegateResult<TResult>, TimeSpan>)
Builds a Policy that will wait and retry as many times as there are provided sleepDurations
calling onRetry
on each retry with the handled exception or result and the current sleep duration.
On each retry, the duration to wait is the current sleepDurations
item.
public static RetryPolicy<TResult> WaitAndRetry<TResult>(this PolicyBuilder<TResult> policyBuilder, IEnumerable<TimeSpan> sleepDurations, Action<DelegateResult<TResult>, TimeSpan> onRetry)
Parameters
policyBuilder
PolicyBuilder<TResult>The policy builder.
sleepDurations
IEnumerable<TimeSpan>The sleep durations to wait for on each retry.
onRetry
Action<DelegateResult<TResult>, TimeSpan>The action to call on each retry.
Returns
- RetryPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
sleepDurations or onRetry
WaitAndRetry<TResult>(PolicyBuilder<TResult>, int, Func<int, Context, TimeSpan>)
Builds a Policy that will wait and retry retryCount
times.
On each retry, the duration to wait is calculated by calling sleepDurationProvider
with
the current retry attempt allowing an exponentially increasing wait time (exponential backoff).
public static RetryPolicy<TResult> WaitAndRetry<TResult>(this PolicyBuilder<TResult> policyBuilder, int retryCount, Func<int, Context, TimeSpan> sleepDurationProvider)
Parameters
policyBuilder
PolicyBuilder<TResult>The policy builder.
retryCount
intThe retry count.
sleepDurationProvider
Func<int, Context, TimeSpan>The function that provides the duration to wait for for a particular retry attempt.
Returns
- RetryPolicy<TResult>
The policy instance.
Type Parameters
TResult
WaitAndRetry<TResult>(PolicyBuilder<TResult>, int, Func<int, Context, TimeSpan>, Action<DelegateResult<TResult>, TimeSpan, Context>)
Builds a Policy that will wait and retry retryCount
times
calling onRetry
on each retry with the handled exception or result, current sleep duration and context data.
On each retry, the duration to wait is calculated by calling sleepDurationProvider
with
the current retry attempt allowing an exponentially increasing wait time (exponential backoff).
public static RetryPolicy<TResult> WaitAndRetry<TResult>(this PolicyBuilder<TResult> policyBuilder, int retryCount, Func<int, Context, TimeSpan> sleepDurationProvider, Action<DelegateResult<TResult>, TimeSpan, Context> onRetry)
Parameters
policyBuilder
PolicyBuilder<TResult>The policy builder.
retryCount
intThe retry count.
sleepDurationProvider
Func<int, Context, TimeSpan>The function that provides the duration to wait for for a particular retry attempt.
onRetry
Action<DelegateResult<TResult>, TimeSpan, Context>The action to call on each retry.
Returns
- RetryPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentOutOfRangeException
retryCount;Value must be greater than or equal to zero.
- ArgumentNullException
sleepDurationProvider or onRetry
WaitAndRetry<TResult>(PolicyBuilder<TResult>, int, Func<int, Context, TimeSpan>, Action<DelegateResult<TResult>, TimeSpan, int, Context>)
Builds a Policy that will wait and retry retryCount
times
calling onRetry
on each retry with the handled exception or result, current sleep duration, retry count, and context data.
On each retry, the duration to wait is calculated by calling sleepDurationProvider
with
the current retry attempt allowing an exponentially increasing wait time (exponential backoff).
public static RetryPolicy<TResult> WaitAndRetry<TResult>(this PolicyBuilder<TResult> policyBuilder, int retryCount, Func<int, Context, TimeSpan> sleepDurationProvider, Action<DelegateResult<TResult>, TimeSpan, int, Context> onRetry)
Parameters
policyBuilder
PolicyBuilder<TResult>The policy builder.
retryCount
intThe retry count.
sleepDurationProvider
Func<int, Context, TimeSpan>The function that provides the duration to wait for for a particular retry attempt.
onRetry
Action<DelegateResult<TResult>, TimeSpan, int, Context>The action to call on each retry.
Returns
- RetryPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentOutOfRangeException
retryCount;Value must be greater than or equal to zero.
- ArgumentNullException
timeSpanProvider or onRetry
WaitAndRetry<TResult>(PolicyBuilder<TResult>, int, Func<int, TimeSpan>)
Builds a Policy that will wait and retry retryCount
times.
On each retry, the duration to wait is calculated by calling sleepDurationProvider
with
the current retry attempt allowing an exponentially increasing wait time (exponential backoff).
public static RetryPolicy<TResult> WaitAndRetry<TResult>(this PolicyBuilder<TResult> policyBuilder, int retryCount, Func<int, TimeSpan> sleepDurationProvider)
Parameters
policyBuilder
PolicyBuilder<TResult>The policy builder.
retryCount
intThe retry count.
sleepDurationProvider
Func<int, TimeSpan>The function that provides the duration to wait for for a particular retry attempt.
Returns
- RetryPolicy<TResult>
The policy instance.
Type Parameters
TResult
WaitAndRetry<TResult>(PolicyBuilder<TResult>, int, Func<int, TimeSpan>, Action<DelegateResult<TResult>, TimeSpan, Context>)
Builds a Policy that will wait and retry retryCount
times
calling onRetry
on each retry with the handled exception or result, current sleep duration and context data.
On each retry, the duration to wait is calculated by calling sleepDurationProvider
with
the current retry attempt allowing an exponentially increasing wait time (exponential backoff).
public static RetryPolicy<TResult> WaitAndRetry<TResult>(this PolicyBuilder<TResult> policyBuilder, int retryCount, Func<int, TimeSpan> sleepDurationProvider, Action<DelegateResult<TResult>, TimeSpan, Context> onRetry)
Parameters
policyBuilder
PolicyBuilder<TResult>The policy builder.
retryCount
intThe retry count.
sleepDurationProvider
Func<int, TimeSpan>The function that provides the duration to wait for for a particular retry attempt.
onRetry
Action<DelegateResult<TResult>, TimeSpan, Context>The action to call on each retry.
Returns
- RetryPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentOutOfRangeException
retryCount;Value must be greater than or equal to zero.
- ArgumentNullException
sleepDurationProvider or onRetry
WaitAndRetry<TResult>(PolicyBuilder<TResult>, int, Func<int, TimeSpan>, Action<DelegateResult<TResult>, TimeSpan, int, Context>)
Builds a Policy that will wait and retry retryCount
times
calling onRetry
on each retry with the handled exception or result, current sleep duration, retry count, and context data.
On each retry, the duration to wait is calculated by calling sleepDurationProvider
with
the current retry attempt allowing an exponentially increasing wait time (exponential backoff).
public static RetryPolicy<TResult> WaitAndRetry<TResult>(this PolicyBuilder<TResult> policyBuilder, int retryCount, Func<int, TimeSpan> sleepDurationProvider, Action<DelegateResult<TResult>, TimeSpan, int, Context> onRetry)
Parameters
policyBuilder
PolicyBuilder<TResult>The policy builder.
retryCount
intThe retry count.
sleepDurationProvider
Func<int, TimeSpan>The function that provides the duration to wait for for a particular retry attempt.
onRetry
Action<DelegateResult<TResult>, TimeSpan, int, Context>The action to call on each retry.
Returns
- RetryPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentOutOfRangeException
retryCount;Value must be greater than or equal to zero.
- ArgumentNullException
timeSpanProvider or onRetry
WaitAndRetry<TResult>(PolicyBuilder<TResult>, int, Func<int, TimeSpan>, Action<DelegateResult<TResult>, TimeSpan>)
Builds a Policy that will wait and retry retryCount
times
calling onRetry
on each retry with the handled exception or result and the current sleep duration.
On each retry, the duration to wait is calculated by calling sleepDurationProvider
with
the current retry attempt allowing an exponentially increasing wait time (exponential backoff).
public static RetryPolicy<TResult> WaitAndRetry<TResult>(this PolicyBuilder<TResult> policyBuilder, int retryCount, Func<int, TimeSpan> sleepDurationProvider, Action<DelegateResult<TResult>, TimeSpan> onRetry)
Parameters
policyBuilder
PolicyBuilder<TResult>The policy builder.
retryCount
intThe retry count.
sleepDurationProvider
Func<int, TimeSpan>The function that provides the duration to wait for for a particular retry attempt.
onRetry
Action<DelegateResult<TResult>, TimeSpan>The action to call on each retry.
Returns
- RetryPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentOutOfRangeException
retryCount;Value must be greater than or equal to zero.
- ArgumentNullException
sleepDurationProvider or onRetry