UniformStrategy Class
- Namespace
- Kampute.HttpClient.RetryManagement.Strategies
- Assembly
- Kampute.HttpClient.dll
Definition
A retry strategy that schedules retries with a uniform delay.
public sealed class UniformStrategy : IRetryStrategy- Inheritance
- object
- UniformStrategy
- Implements
Remarks
The UniformStrategy class provides a retry mechanism with a constant wait time between retries. This strategy is useful for scenarios where a predictable retry pattern is desired, applying the same delay duration between each retry attempt without regard to the number of attempts made or the total elapsed time.
Constructors
UniformStrategy(TimeSpan)
Initializes a new instance of the UniformStrategy class with a specified delay duration between retry attempts.
public UniformStrategy(TimeSpan delay)Parameters
delayTimeSpan- The delay duration between retry attempts.
Properties
Delay
Gets the delay duration between retries.
public TimeSpan Delay { get; }Property Value
- TimeSpan
- The delay duration between retries.
Methods
TryGetRetryDelay(TimeSpan, uint, out TimeSpan)
Returns a uniform delay for every retry attempt.
public bool TryGetRetryDelay(TimeSpan elapsed, uint attempts, out TimeSpan delay)Parameters
elapsedTimeSpan- The total time elapsed since the start of retry attempts. This parameter is ignored in this implementation.
attemptsuint- The number of retry attempts made so far. This parameter is ignored in this implementation.
delayTimeSpan- When this method returns, contains the calculated delay for the next retry attempt. This parameter is passed uninitialized.
Returns
Extension Methods
| ToBackoffStrategy(this IRetryStrategy) | Converts an IRetryStrategy into a BackoffStrategy, creating a factory capable of producing schedulers based on the provided strategy. |
| ToScheduler(this IRetryStrategy) | Converts an IRetryStrategy into a RetryScheduler, creating a scheduler instance based on the provided strategy. |
| WithJitter(this IRetryStrategy, double) | Enhances a retry strategy with jitter to add randomness to the retry delay. |
| WithMaxAttempts(this IRetryStrategy, uint) | Enhances a retry strategy with a maximum number of retry attempts. |
| WithTimeout(this IRetryStrategy, TimeSpan) | Enhances a retry strategy with a timeout, limiting the total duration allowed for retry attempts. |
