Table of Contents

Class RetryScheduler

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

Represents a scheduler for managing retry attempts.

public class RetryScheduler : IRetryScheduler
Inheritance
RetryScheduler
Implements
Inherited Members

Constructors

RetryScheduler(IRetryStrategy)

Initializes a new instance of the RetryScheduler class with a specified retry strategy.

public RetryScheduler(IRetryStrategy strategy)

Parameters

strategy IRetryStrategy

The retry strategy to be used by this scheduler.

Exceptions

ArgumentNullException

Thrown if strategy is null.

Properties

Attempts

Gets the number of retry attempts that have been made.

public virtual uint Attempts { get; }

Property Value

uint

Elapsed

Gets the total elapsed time since the retry attempts were started.

public virtual TimeSpan Elapsed { get; }

Property Value

TimeSpan

Strategy

Gets the retry strategy associated with this scheduler.

public virtual IRetryStrategy Strategy { get; }

Property Value

IRetryStrategy

Methods

ReadyNextAttempt()

Prepares the internal state for the next retry attempt.

protected virtual void ReadyNextAttempt()

Remarks

This method is called immediately after a retry attempt is determined to be necessary and before the delay for the next attempt begins. It allows for updating the internal state or performing any preparations required before the next attempt.

Reset()

Resets the internal state of the scheduler to its initial condition.

public virtual void Reset()

WaitAsync(CancellationToken)

Waits for the appropriate time before the next retry attempt, and determines if a retry should be attempted.

public virtual Task<bool> WaitAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

A token that can be used to cancel the wait operation.

Returns

Task<bool>

A task that resolves to true if a retry should be attempted; otherwise, false.

Exceptions

OperationCanceledException

Thrown if the wait operation is canceled.