class Sidetiq::Clock

Public: The Sidetiq clock.

Attributes

schedules[R]

Internal: Returns a hash of Sidetiq::Schedule instances.

Public Class Methods

start!() click to toggle source
# File lib/sidetiq/clock.rb, line 6
def self.start!
  warn "Sidetiq::Clock#start! is deprecated. Calling it is no longer required."
end

Public Instance Methods

gettime() click to toggle source

Public: Returns the current time used by the clock.

Examples

gettime
# => 2013-02-04 12:00:45 +0000

Returns a Time instance.

# File lib/sidetiq/clock.rb, line 59
def gettime
  Sidetiq.config.utc ? Time.now.utc : (Time.respond_to?(:current) ? Time.current : Time.now)
end
schedule_for(worker) click to toggle source

Public: Get the schedule for `worker`.

worker - A Sidekiq::Worker class

Examples

schedule_for(MyWorker)
# => Sidetiq::Schedule

Returns a Sidetiq::Schedule instances.

# File lib/sidetiq/clock.rb, line 31
def schedule_for(worker)
  if worker.respond_to?(:schedule)
    worker.schedule
  end
end
start!() click to toggle source
# File lib/sidetiq/clock.rb, line 10
def start!
  warn "Sidetiq::Clock#start! is deprecated. Calling it is no longer required."
end
tick(tick = gettime) click to toggle source

Public: Issue a single clock tick.

Examples

tick
# => Hash of Sidetiq::Schedule objects

Returns a hash of Sidetiq::Schedule instances.

# File lib/sidetiq/clock.rb, line 45
def tick(tick = gettime)
  Sidetiq.workers.each do |worker|
    Sidetiq.handler.dispatch(worker, tick)
  end
end