Interface IRetryPolicy
- Namespace
- Excalibur.Dispatch.Resilience
- Assembly
- Excalibur.Dispatch.dll
Retry policy interface for executing operations with retry logic, carrying no third-party types.
public interface IRetryPolicy
- Extension Methods
Remarks
This interface provides a minimal abstraction for retry policies that does not depend on any external libraries like Polly. It keeps Polly off the core Dispatch package's dependency list while still supporting advanced retry implementations via optional packages.
Default implementations include:
- Excalibur.Dispatch.Resilience.NoOpRetryPolicy - Pass-through policy that doesn't retry
For Polly-based implementations, use the Excalibur.Dispatch.Resilience.Polly package.
Methods
ExecuteAsync(Func<CancellationToken, Task>, CancellationToken)
Executes an async operation with retry logic.
Task ExecuteAsync(Func<CancellationToken, Task> action, CancellationToken cancellationToken)
Parameters
actionFunc<CancellationToken, Task>The operation to execute.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
- Task
A task representing the async operation.
Exceptions
- ArgumentNullException
Thrown when
actionis null.- Exception
The last exception thrown after all retry attempts are exhausted.
ExecuteAsync<TResult>(Func<CancellationToken, Task<TResult>>, CancellationToken)
Executes an async operation with retry logic.
Task<TResult> ExecuteAsync<TResult>(Func<CancellationToken, Task<TResult>> action, CancellationToken cancellationToken)
Parameters
actionFunc<CancellationToken, Task<TResult>>The operation to execute.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
- Task<TResult>
The result of the operation.
Type Parameters
TResultThe return type of the operation.
Exceptions
- ArgumentNullException
Thrown when
actionis null.- Exception
The last exception thrown after all retry attempts are exhausted.