Table of Contents

Class FibonacciStrategy

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

A retry strategy that increases the delay before each retry attempt based on the Fibonacci sequence.

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

Remarks

The FibonacciStrategy class uses the Fibonacci sequence to adjust the wait time between retries, starting with an initial delay and scaling the delay between subsequent attempts according to Fibonacci numbers. This approach provides a more moderate and controlled increase in delay times compared to the ExponentialStrategy approach, making it suitable for scenarios where a less aggressive increase in delay is desired.

Constructors

FibonacciStrategy(TimeSpan)

Initializes a new instance of the FibonacciStrategy class with a specified initial delay.

public FibonacciStrategy(TimeSpan initialDelay)

Parameters

initialDelay TimeSpan

The initial delay duration before the first retry attempt.

FibonacciStrategy(TimeSpan, TimeSpan)

Initializes a new instance of the FibonacciStrategy class with a specified initial delay and step increment.

public FibonacciStrategy(TimeSpan initialDelay, TimeSpan delayStep)

Parameters

initialDelay TimeSpan

The initial delay duration before the first retry attempt.

delayStep TimeSpan

The fixed amount of time that is scaled by the Fibonacci sequence and added to the initial delay for each subsequent retry attempt.

Properties

DelayStep

Gets the fixed amount of time that is scaled by the Fibonacci sequence and added to the initial delay for each subsequent retry attempt.

public TimeSpan DelayStep { get; }

Property Value

TimeSpan

The fixed amount of time that is scaled by the Fibonacci sequence and added to the initial delay for each subsequent retry attempt.

InitialDelay

Gets the initial delay duration before the first retry attempt.

public TimeSpan InitialDelay { get; }

Property Value

TimeSpan

The initial delay duration before the first retry attempt.

Methods

TryGetRetryDelay(TimeSpan, uint, out TimeSpan)

Calculates the delay for the next retry attempt based on the Fibonacci sequence.

public bool TryGetRetryDelay(TimeSpan elapsed, uint attempts, out TimeSpan delay)

Parameters

elapsed TimeSpan

The total time elapsed since the start of retry attempts. This parameter is ignored in this implementation.

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

Always returns true, indicating that a retry attempt should be made after the calculated delay.