Class: Sidekiq::Ultimate::IntervalWithJitter

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq/ultimate/interval_with_jitter.rb

Overview

Util class to add a jitter to the interval

Constant Summary collapse

RANDOM_OFFSET_RATIO =
0.1

Class Method Summary collapse

Class Method Details

.call(interval) ⇒ Object

Returns execution interval with jitter. Jitter is +- RANDOM_OFFSET_RATIO from the original value.



12
13
14
15
# File 'lib/sidekiq/ultimate/interval_with_jitter.rb', line 12

def call(interval)
  jitter_factor = 1 + rand(-RANDOM_OFFSET_RATIO..RANDOM_OFFSET_RATIO)
  jitter_factor * interval
end