Table of Contents

Class PollyRetryPolicyAdapter

Namespace
Excalibur.Dispatch.Resilience.Polly
Assembly
Excalibur.Dispatch.Resilience.Polly.dll

Polly-based retry policy implementation that wraps Polly's resilience pipeline and implements the core IRetryPolicy interface.

public sealed class PollyRetryPolicyAdapter : IRetryPolicy
Inheritance
PollyRetryPolicyAdapter
Implements
Inherited Members
Extension Methods

Remarks

This adapter bridges Polly's powerful retry capabilities with Dispatch's zero-dependency retry abstraction. Use this when you want Polly's advanced features like jitter strategies, circuit breaker integration, or custom should-handle predicates.

For consumers who don't need Polly's advanced features, the core package provides the in-box policies, which use IBackoffCalculator for delays.

Constructors

PollyRetryPolicyAdapter(IOptions<PollyRetryOptions>, ILogger?)

Initializes a new instance of the PollyRetryPolicyAdapter class.

public PollyRetryPolicyAdapter(IOptions<PollyRetryOptions> options, ILogger? logger = null)

Parameters

options IOptions<PollyRetryOptions>

Retry configuration options.

logger ILogger

Optional logger instance.

Methods

ExecuteAsync(Func<CancellationToken, Task>, CancellationToken)

Executes an async operation with retry logic.

public 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.

Remarks

Executes the action through Polly's resilience pipeline with full retry, circuit breaker, and jitter support based on PollyRetryOptions configuration.

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.

public 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.

Remarks

Executes the action through Polly's resilience pipeline with full retry, circuit breaker, and jitter support based on PollyRetryOptions configuration.

Exceptions

ArgumentNullException

Thrown when action is null.

Exception

The last exception thrown after all retry attempts are exhausted.