Method: Webhookdb::SyncTarget#jitter

Defined in:
lib/webhookdb/sync_target.rb

#jitterObject

Return the jitter used for enqueing the next sync of the job. It should never be more than 20 seconds, nor should it be more than 1/4 of the total period, since it needs to run at a reasonably predictable time. Jitter is always >= 1, since it is helpful to be able to assert it will always be in the future.



225
226
227
228
229
# File 'lib/webhookdb/sync_target.rb', line 225

def jitter
  max_jitter = [20, self.period_seconds / 4].min
  max_jitter = [1, max_jitter].max
  return RAND.rand(1..max_jitter)
end