Module: CMDx::Retriers::HalfRandom Private

Extended by:
HalfRandom
Included in:
HalfRandom
Defined in:
lib/cmdx/retriers/half_random.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.

Half-random jitter. Produces a uniform delay in ‘[delay/2, delay]`. Useful when you want a tighter spread than `:full_random` while still decorrelating retries from synchronized clients.

Instance Method Summary collapse

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.

Parameters:

  • _attempt (Integer)

    ignored

  • delay (Float)

    base delay in seconds

  • _prev_delay (Float, nil) (defaults to: nil)

    ignored

Returns:

  • (Float)

    computed delay



18
19
20
# File 'lib/cmdx/retriers/half_random.rb', line 18

def call(_attempt, delay, _prev_delay = nil)
  (delay / 2.0) + (rand * delay / 2.0)
end