olp-cpp-sdk  1.18.1
Public Member Functions | List of all members
olp::client::ExponentialBackdownStrategy Struct Reference

Computes wait time for the next retry attempt via the exponential backoff with the added jitter. More...

#include <BackdownStrategy.h>

Public Member Functions

std::chrono::milliseconds operator() (std::chrono::milliseconds initial_backdown_period, size_t retry_count)
 Computes the next retry attempt wait time based on the number of retries and initial backdown period. More...
 

Detailed Description

Computes wait time for the next retry attempt via the exponential backoff with the added jitter.

This backoff strategy is based on the exponential wait-time approach. For example, when the wait time exponentially grows with each retry attempt, but randomization is added. See https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/

The actual formula can be described in the following way:

wait_time = random_between(0, initial_backdown_period_msec * (2 ^
retry_count))

Member Function Documentation

◆ operator()()

std::chrono::milliseconds olp::client::ExponentialBackdownStrategy::operator() ( std::chrono::milliseconds  initial_backdown_period,
size_t  retry_count 
)
inline

Computes the next retry attempt wait time based on the number of retries and initial backdown period.

Parameters
initial_backdown_periodThe initial backdown period.
retry_countThe number of retries that are already made.
Returns
The timeout for the next retry attempt.

The documentation for this struct was generated from the following file: