BackoffStrategy Class

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

Definition

A factory for creating RetryScheduler instances configured with a specific retry strategy.
public class BackoffStrategy : IHttpBackoffProvider
Inheritance
Implements

Remarks

This factory encapsulates the creation logic of retry schedulers, allowing for consistent configuration of schedulers across an application. It uses a designated retry strategy to configure each scheduler it creates, ensuring that all schedulers have a uniform approach to handling retry attempts.

Constructors

BackoffStrategy(IRetryStrategy)

Initializes a new instance of the BackoffStrategy class with a specified retry strategy.
public BackoffStrategy(IRetryStrategy strategy)

Parameters

strategy IRetryStrategy
The retry strategy to be used by schedulers created by this factory.

Exceptions

ArgumentNullException
Thrown if strategy is null.

Properties

Strategy

Gets the retry strategy associated with this scheduler factory.
public virtual IRetryStrategy Strategy { get; }

Property Value

IRetryStrategy
The IRetryStrategy used by schedulers created by this factory.

Methods

CreateScheduler()

Creates a RetryScheduler instance using the associated retry strategy.
public virtual IRetryScheduler CreateScheduler()

Returns

IRetryScheduler
A new instance of RetryScheduler configured with the factory's retry strategy.

Explicit Interface Implementations

IHttpBackoffProvider.CreateScheduler(HttpRequestErrorContext)

Creates a scheduler responsible for managing retry attempts for HTTP requests, based on a specified retry strategy.
IRetryScheduler IHttpBackoffProvider.CreateScheduler(HttpRequestErrorContext ctx)

Parameters

ctx HttpRequestErrorContext
Provides context containing detailed information about the failed HTTP request, including client, request, and error specifics.

Returns

IRetryScheduler
An instance of IRetryScheduler that coordinates the retry attempts for the given context according to the defined strategy.

Exceptions

ArgumentNullException
Thrown if ctx is null.