IRetryStrategy Interface

Namespace
Kampute.HttpClient.Interfaces
Assembly
  • Kampute.HttpClient.dll

Definition

Defines a strategy for calculating the delay duration between retry attempts based on elapsed time and the number of attempts already made.
public interface IRetryStrategy
Implemented by

Methods

TryGetRetryDelay(TimeSpan, uint, out TimeSpan)

Calculates the delay duration for the next retry attempt and indicates whether a retry should be attempted.
bool TryGetRetryDelay(TimeSpan elapsed, uint attempts, out TimeSpan delay)

Parameters

elapsed TimeSpan
The total time elapsed since the start of retry attempts.
attempts uint
The count of retry attempts made so far.
delay TimeSpan
When this method returns, contains the calculated delay duration for the next retry attempt, if a retry is advisable. This parameter is passed uninitialized.

Returns

bool
true if a retry attempt is advisable and should be made after the calculated delay; false otherwise, indicating no further retry attempts should be made.

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.