Table of Contents

Class LimitedAttemptsStrategyModifier

Namespace
Kampute.HttpClient.RetryManagement.Strategies.Modifiers
Assembly
Kampute.HttpClient.dll

A retry strategy that limits the number of retry attempts to a specified maximum.

public sealed class LimitedAttemptsStrategyModifier : IRetryStrategy
Inheritance
LimitedAttemptsStrategyModifier
Implements
Inherited Members
Extension Methods

Remarks

This class wraps another strategy and enforces a maximum number of attempts. Once the limit is reached, no further retries are suggested.

Constructors

LimitedAttemptsStrategyModifier(IRetryStrategy, uint)

Initializes a new instance of the LimitedAttemptsStrategyModifier class with a specified source provider and maximum number of attempts.

public LimitedAttemptsStrategyModifier(IRetryStrategy source, uint maxAttempts)

Parameters

source IRetryStrategy

The underlying retry strategy.

maxAttempts uint

The maximum number of retry attempts before giving up.

Exceptions

ArgumentNullException

Thrown if source is null.

Properties

MaxAttempts

Gets the maximum number of retry attempts before giving up.

public uint MaxAttempts { get; }

Property Value

uint

The maximum number of retry attempts before giving up.

Source

Gets the underlying retry strategy, to which the specified maximum number of retry attempts is applied as a limit.

public IRetryStrategy Source { get; }

Property Value

IRetryStrategy

The underlying IRetryStrategy, to which the specified maximum number of retry attempts is applied as a limit.

Methods

TryGetRetryDelay(TimeSpan, uint, out TimeSpan)

Calculates the delay for the next retry attempt, enforcing the maximum attempt limit.

public 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 number of retry attempts made so far.

delay TimeSpan

When this method returns, contains the calculated delay for the next retry attempt. This parameter is passed uninitialized.

Returns

bool

true if the number of attempts has not yet reached the maximum and the underlying strategy indicates that a retry should be attempted; otherwise, false.