Table of Contents

Class RetryStrategyExtensions

Namespace
Kampute.HttpClient.RetryManagement
Assembly
Kampute.HttpClient.dll

Provides extension methods for IRetryStrategy to enhance retry strategies with additional behavior.

public static class RetryStrategyExtensions
Inheritance
RetryStrategyExtensions
Inherited Members

Methods

ToBackoffStrategy(IRetryStrategy)

Converts an IRetryStrategy into a BackoffStrategy, creating a factory capable of producing schedulers based on the provided strategy.

public static BackoffStrategy ToBackoffStrategy(this IRetryStrategy source)

Parameters

source IRetryStrategy

The retry strategy to use for creating a scheduler factory.

Returns

BackoffStrategy

A new instance of BackoffStrategy.

Exceptions

ArgumentNullException

Thrown if source is null.

ToScheduler(IRetryStrategy)

Converts an IRetryStrategy into a RetryScheduler, creating a scheduler instance based on the provided strategy.

public static RetryScheduler ToScheduler(this IRetryStrategy source)

Parameters

source IRetryStrategy

The retry strategy to convert into a scheduler.

Returns

RetryScheduler

A new instance of RetryScheduler.

Exceptions

ArgumentNullException

Thrown if source is null.

WithJitter(IRetryStrategy, double)

Enhances a retry strategy with jitter to add randomness to the retry delay.

public static JitterStrategyModifier WithJitter(this IRetryStrategy source, double jitterFactor = 0.5)

Parameters

source IRetryStrategy

The original retry strategy to be enhanced.

jitterFactor double

The factor by which to adjust the delay randomly, with a default of 0.5.

Returns

JitterStrategyModifier

A JitterStrategyModifier instance wrapping the original retry strategy with added jitter.

Exceptions

ArgumentNullException

Thrown if source is null.

ArgumentOutOfRangeException

Thrown if jitterFactor is not between 0 and 1.

WithMaxAttempts(IRetryStrategy, uint)

Enhances a retry strategy with a maximum number of retry attempts.

public static LimitedAttemptsStrategyModifier WithMaxAttempts(this IRetryStrategy source, uint maxAttempts)

Parameters

source IRetryStrategy

The original retry strategy to be enhanced.

maxAttempts uint

The maximum number of attempts allowed before giving up.

Returns

LimitedAttemptsStrategyModifier

A LimitedAttemptsStrategyModifier instance wrapping the original retry strategy with a limit on the number of attempts.

Exceptions

ArgumentNullException

Thrown if source is null.

WithTimeout(IRetryStrategy, TimeSpan)

Enhances a retry strategy with a timeout, limiting the total duration allowed for retry attempts.

public static LimitedDurationStrategyModifier WithTimeout(this IRetryStrategy source, TimeSpan timeout)

Parameters

source IRetryStrategy

The original retry strategy to be enhanced.

timeout TimeSpan

The maximum duration to attempt retries before giving up.

Returns

LimitedDurationStrategyModifier

A LimitedDurationStrategyModifier instance wrapping the original retry strategy with a timeout limit.

Exceptions

ArgumentNullException

Thrown if source is null.