Class: Sidetiq::Clock
Overview
Public: The Sidetiq clock.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#schedules ⇒ Object
readonly
Internal: Returns a hash of Sidetiq::Schedule instances.
Class Method Summary collapse
Instance Method Summary collapse
-
#gettime ⇒ Object
Public: Returns the current time used by the clock.
-
#initialize ⇒ Clock
constructor
:nodoc:.
-
#schedule_for(worker) ⇒ Object
Public: Get the schedule for ‘worker`.
- #start! ⇒ Object
-
#tick(tick = gettime) ⇒ Object
Public: Issue a single clock tick.
Constructor Details
#initialize ⇒ Clock
:nodoc:
17 18 19 |
# File 'lib/sidetiq/clock.rb', line 17 def initialize # :nodoc: super end |
Instance Attribute Details
#schedules ⇒ Object (readonly)
Internal: Returns a hash of Sidetiq::Schedule instances.
15 16 17 |
# File 'lib/sidetiq/clock.rb', line 15 def schedules @schedules end |
Class Method Details
.start! ⇒ Object
6 7 8 |
# File 'lib/sidetiq/clock.rb', line 6 def self.start! warn "Sidetiq::Clock#start! is deprecated. Calling it is no longer required." end |
Instance Method Details
#gettime ⇒ Object
Public: Returns the current time used by the clock.
Examples
gettime
# => 2013-02-04 12:00:45 +0000
Returns a Time instance.
59 60 61 |
# 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) ⇒ Object
Public: Get the schedule for ‘worker`.
worker - A Sidekiq::Worker class
Examples
schedule_for(MyWorker)
# => Sidetiq::Schedule
Returns a Sidetiq::Schedule instances.
31 32 33 34 35 |
# File 'lib/sidetiq/clock.rb', line 31 def schedule_for(worker) if worker.respond_to?(:schedule) worker.schedule end end |
#start! ⇒ Object
10 11 12 |
# 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) ⇒ Object
Public: Issue a single clock tick.
Examples
tick
# => Hash of Sidetiq::Schedule objects
Returns a hash of Sidetiq::Schedule instances.
45 46 47 48 49 |
# File 'lib/sidetiq/clock.rb', line 45 def tick(tick = gettime) Sidetiq.workers.each do |worker| Sidetiq.handler.dispatch(worker, tick) end end |