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
IRetryStrategyThe 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
IRetryStrategyThe 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
IRetryStrategyThe original retry strategy to be enhanced.
jitterFactor
doubleThe 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
IRetryStrategyThe original retry strategy to be enhanced.
maxAttempts
uintThe 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
IRetryStrategyThe original retry strategy to be enhanced.
timeout
TimeSpanThe 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.