Class RetryHelper
- Namespace
- FoundationaLLM.Common.Utils
- Assembly
- FoundationaLLM.Common.dll
Provides helper methods for implementing retry logic in applications.
public static class RetryHelper
- Inheritance
-
RetryHelper
- Inherited Members
Remarks
This class typically contains static methods that assist with executing operations that may need to be retried due to transient failures, such as network errors or temporary unavailability of resources. It is intended to be used as a utility and cannot be instantiated.
Fields
DefaultResiliencePipeline
Gets the default resilience pipeline configured with a retry strategy.
public static readonly ResiliencePipeline DefaultResiliencePipeline
Field Value
Remarks
The default pipeline is configured to retry failed operations up to five times with a one-second delay between attempts. This pipeline can be used as a starting point for common resilience scenarios or as a baseline for further customization.
Methods
ExecuteWithRetryAsync(Func<Task>)
Executes the specified asynchronous action using a default resilience pipeline that automatically retries on transient failures.
public static ValueTask ExecuteWithRetryAsync(Func<Task> action)
Parameters
actionFunc<Task>A delegate that represents the asynchronous operation to execute. The delegate should return a task that completes when the operation is finished.
Returns
- ValueTask
A ValueTask that represents the asynchronous execution of the action, including any retries performed by the resilience pipeline.