Table of Contents

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

maxRetryAttempts int

The maximum number of attempts to perform before rethrowing.

operation Func<CancellationToken, Task>

The asynchronous operation to execute.

logger ILogger

The logger used to record retry attempts and terminal failures.

cancellationToken CancellationToken

The cancellation token that is observed across retries.

Returns

Task

Type Parameters

TException

The 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

maxRetryAttempts int

The maximum number of attempts to perform before rethrowing.

operation Func<Task>

The asynchronous operation to execute.

logger ILogger

The logger used to record retry attempts and terminal failures.

Returns

Task

Type Parameters

TException

The 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

maxRetryAttempts int

The maximum number of attempts to perform before returning or rethrowing.

operation Func<CancellationToken, Task<TResult>>

The asynchronous operation to execute.

shouldRetryResult Func<TResult, bool>

The predicate that determines whether a returned result should be retried.

shouldRetryException Func<Exception, bool>

The predicate that determines whether a thrown exception should be retried.

logger ILogger

The logger used to record retry attempts and terminal failures.

retryDelaySelector Func<TResult, TimeSpan?>

The optional selector that chooses a delay for retryable results.

cancellationToken CancellationToken

The 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

TResult

The result type returned by the operation.

To top