Class RetryHelper
- Namespace
- Dynamicweb.DataIntegration.Providers.ODataProvider.Model
- Assembly
- Dynamicweb.DataIntegration.dll
Provides retry helpers for transient OData operations.
public static class RetryHelper
- Inheritance
-
RetryHelper
- Inherited Members
Methods
RetryOnExceptionAsync<TException>(int, Func<CancellationToken, Task>, ILogger?, CancellationToken)
Retries an asynchronous operation when it throws the specified exception type and observes cancellation across retries.
public static Task RetryOnExceptionAsync<TException>(int maxRetryAttempts, Func<CancellationToken, Task> operation, ILogger? logger, CancellationToken cancellationToken) where TException : Exception
Parameters
maxRetryAttemptsintThe maximum number of attempts to perform before rethrowing.
operationFunc<CancellationToken, Task>The asynchronous operation to execute.
loggerILoggerThe logger used to record retry attempts and terminal failures.
cancellationTokenCancellationTokenThe cancellation token that is observed across retries.
Returns
Type Parameters
TExceptionThe exception type that should trigger a retry.
RetryOnExceptionAsync<TException>(int, Func<Task>, ILogger?)
Retries an asynchronous operation when it throws the specified exception type.
public static Task RetryOnExceptionAsync<TException>(int maxRetryAttempts, Func<Task> operation, ILogger? logger) where TException : Exception
Parameters
maxRetryAttemptsintThe maximum number of attempts to perform before rethrowing.
operationFunc<Task>The asynchronous operation to execute.
loggerILoggerThe logger used to record retry attempts and terminal failures.
Returns
Type Parameters
TExceptionThe exception type that should trigger a retry.
RetryOnExceptionOrResultAsync<TResult>(int, Func<CancellationToken, Task<TResult>>, Func<TResult, bool>, Func<Exception, bool>, ILogger?, Func<TResult, TimeSpan?>?, CancellationToken)
Retries an asynchronous operation when either its result or its exception indicates a transient failure.
public static Task<TResult> RetryOnExceptionOrResultAsync<TResult>(int maxRetryAttempts, Func<CancellationToken, Task<TResult>> operation, Func<TResult, bool> shouldRetryResult, Func<Exception, bool> shouldRetryException, ILogger? logger, Func<TResult, TimeSpan?>? retryDelaySelector = null, CancellationToken cancellationToken = default)
Parameters
maxRetryAttemptsintThe maximum number of attempts to perform before returning or rethrowing.
operationFunc<CancellationToken, Task<TResult>>The asynchronous operation to execute.
shouldRetryResultFunc<TResult, bool>The predicate that determines whether a returned result should be retried.
shouldRetryExceptionFunc<Exception, bool>The predicate that determines whether a thrown exception should be retried.
loggerILoggerThe logger used to record retry attempts and terminal failures.
retryDelaySelectorFunc<TResult, TimeSpan?>The optional selector that chooses a delay for retryable results.
cancellationTokenCancellationTokenThe cancellation token that is observed across retries.
Returns
- Task<TResult>
The final successful result, or the last retryable result when the maximum attempt count is reached.
Type Parameters
TResultThe result type returned by the operation.