Table of Contents

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

action Func<CancellationToken, Task>

The operation to execute.

cancellationToken CancellationToken

Token to cancel the operation.

Returns

Task

A task representing the async operation.

Exceptions

ArgumentNullException

Thrown when action is 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

action Func<CancellationToken, Task<TResult>>

The operation to execute.

cancellationToken CancellationToken

Token to cancel the operation.

Returns

Task<TResult>

The result of the operation.

Type Parameters

TResult

The return type of the operation.

Exceptions

ArgumentNullException

Thrown when action is null.

Exception

The last exception thrown after all retry attempts are exhausted.