module Sidekiq::Dejavu::Helper

Public Instance Methods

next_randomized_timestamp(interval, time = Time.now) click to toggle source
# File lib/sidekiq/dejavu/helper.rb, line 19
def next_randomized_timestamp(interval, time = Time.now)
  diff = CronParser.new(interval).next(time).to_f - time.to_f
  time.to_f + Random.rand(diff)
rescue ArgumentError
  time.to_f + Random.rand(interval.to_f)
end
next_timestamp(interval, time = Time.now) click to toggle source
# File lib/sidekiq/dejavu/helper.rb, line 13
def next_timestamp(interval, time = Time.now)
  CronParser.new(interval).next(time).to_f
rescue ArgumentError
  time.to_f + interval.to_f
end
valid_cron?(interval) click to toggle source
# File lib/sidekiq/dejavu/helper.rb, line 6
def valid_cron?(interval)
  CronParser.new(interval)
  true
rescue ArgumentError
  false
end