10 using Delay = std::chrono::milliseconds;
17 , _maxRetryAfter(maxRetryAfter)
25 return std::clamp(retryAfter, _delay, (std::max) (_delay, _maxRetryAfter));
32 const auto grown = _delay * _factor;
33 _delay = grown < _cap ? std::chrono::duration_cast<Delay>(grown) : _cap;
45 constexpr int attempts()
const {
return _attempts; }
Retry delays that start at an initial value and grow by a factor per attempt, up to a cap.
constexpr int attempts() const
Attempts counted since construction or the last reset().
std::chrono::milliseconds Delay
constexpr Delay peek(Delay retryAfter=Delay::zero()) const
constexpr Delay next(Delay retryAfter=Delay::zero())
Returns peek(retryAfter) and counts the attempt.
constexpr ExponentialBackoff(Delay initial, double factor, Delay cap, Delay maxRetryAfter=Delay::zero())
A positive maxRetryAfter lets a server's retry-after hint lengthen a delay, up to that limit.