olp-cpp-sdk  1.18.1
Public Member Functions | List of all members
olp::client::EqualJitterBackdownStrategy 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

 EqualJitterBackdownStrategy (std::chrono::milliseconds cap=std::chrono::seconds(1))
 Creates a EqualJitterBackdownStrategy instance. More...
 
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 Equal Jitter approach. See https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/

The actual formula can be described in the following way:

temp = min(cap, base * 2 ** attempt)
sleep = temp / 2 + random_between(0, temp / 2)

Constructor & Destructor Documentation

◆ EqualJitterBackdownStrategy()

olp::client::EqualJitterBackdownStrategy::EqualJitterBackdownStrategy ( std::chrono::milliseconds  cap = std::chrono::seconds(1))
inlineexplicit

Creates a EqualJitterBackdownStrategy instance.

Parameters
capThe maximum cap used in the wait time formula.

Member Function Documentation

◆ operator()()

std::chrono::milliseconds olp::client::EqualJitterBackdownStrategy::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: