struct
Crabbit::RecoveryPolicy
- Crabbit::RecoveryPolicy
- Struct
- Value
- Object
Overview
Exponential-backoff policy used when a producer or consumer reconnects.
Defined in:
crabbit/options.crConstructors
-
.new(initial_delay : Time::Span = 250.milliseconds, max_delay : Time::Span = 30.seconds, multiplier : Float64 = 2.0, jitter : Float64 = 0.2)
Creates a recovery policy.
Instance Method Summary
-
#delay(attempt : Int) : Time::Span
Returns the randomized delay for the zero-based retry attempt.
-
#initial_delay : Time::Span
Returns the delay before the first retry.
-
#jitter : Float64
Returns the proportional random jitter in the range
0.0..1.0. -
#max_delay : Time::Span
Returns the maximum delay between retries.
-
#multiplier : Float64
Returns the exponential multiplier applied after each failed attempt.
Constructor Detail
def self.new(initial_delay : Time::Span = 250.milliseconds, max_delay : Time::Span = 30.seconds, multiplier : Float64 = 2.0, jitter : Float64 = 0.2)
#
Creates a recovery policy.
Delays grow as initial_delay * multiplier ** attempt, are capped at
max_delay, and are randomized by up to jitter in either direction.
Instance Method Detail
def delay(attempt : Int) : Time::Span
#
Returns the randomized delay for the zero-based retry attempt.