Module: CMDx::Retriers::DecorrelatedJitter Private
- Extended by:
- DecorrelatedJitter
- Included in:
- DecorrelatedJitter
- Defined in:
- lib/cmdx/retriers/decorrelated_jitter.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
AWS-recommended decorrelated jitter. Produces a uniform delay in ‘[delay, max(prev_delay * 3, delay)]`, threading state across attempts via `prev_delay`. When no previous delay exists the upper bound collapses to `3 * delay`, matching the AWS reference implementation. The lower bound is pinned at `delay` even when `prev_delay * 3 < delay` (e.g. after `:max_delay` clamping or mixed strategies), guaranteeing the returned value is never below the configured base.
Instance Method Summary collapse
-
#call(_attempt, delay, prev_delay = nil) ⇒ Float
private
Computed delay, never less than ‘delay`.
Instance Method Details
#call(_attempt, delay, prev_delay = nil) ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns computed delay, never less than ‘delay`.
24 25 26 27 28 29 |
# File 'lib/cmdx/retriers/decorrelated_jitter.rb', line 24 def call(_attempt, delay, prev_delay = nil) base = prev_delay || delay high = base * 3 high = delay if high < delay delay + (rand * (high - delay)) end |