struct

YandexDisk::RetryPolicy

Inherits Struct < Value < Object

Exponential backoff with full-range jitter.

delay_for(1) returns roughly base_delay, delay_for(2) roughly twice that, and so on, clamped at max_delay and then randomised by ±jitter so that a fleet of servers retrying at once does not stay in lockstep.

Constants

JITTER_RANDOM = Random.new

Shared across fibers on purpose: this only smears retry timings apart, so contention on the generator is cheaper than one instance per call.

Constructors

new(max_attempts : Int32 = 5, base_delay : Time::Span = 1.second, max_delay : Time::Span = 60.seconds, jitter : Float64 = 0.25)
Source

Instance methods

base_delay
Source
delay_for(attempt : Int32, random : Random = JITTER_RANDOM) : Time::Span
Source
jitter
Source
max_attempts
Source
max_delay
Source
run(label : String, & : Int32 -> T) : T forall T

Runs block, retrying while the raised error reports itself retryable.

label only shows up in the log line, to make a stalled sync readable.

Source