mirror of
https://github.com/endofunky/sidetiq.git
synced 2022-11-09 13:53:30 -05:00
Add Sidetiq.schedules.
This commit is contained in:
parent
d4b7761dde
commit
5058048ae3
4 changed files with 23 additions and 2 deletions
|
@ -20,5 +20,11 @@ require 'sidetiq/version'
|
|||
|
||||
# The Sidetiq namespace.
|
||||
module Sidetiq
|
||||
# Public: Returns a Hash of Sidetiq::Schedule instances.
|
||||
def self.schedules
|
||||
Clock.synchronize do
|
||||
Clock.schedules.dup
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -15,10 +15,10 @@ module Sidetiq
|
|||
# times in the Sidetiq schedules.
|
||||
START_TIME = Sidetiq.config.utc ? Time.utc(2010, 1, 1) : Time.local(2010, 1, 1)
|
||||
|
||||
# Public: Returns a hash of Sidetiq::Schedule instances.
|
||||
# Internal: Returns a hash of Sidetiq::Schedule instances.
|
||||
attr_reader :schedules
|
||||
|
||||
# Public: Returns the clock thread.
|
||||
# Internal: Returns the clock thread.
|
||||
attr_reader :thread
|
||||
|
||||
def self.method_missing(meth, *args, &block) # :nodoc:
|
||||
|
@ -90,6 +90,7 @@ module Sidetiq
|
|||
return if ticking?
|
||||
|
||||
Sidekiq.logger.info "Sidetiq::Clock start"
|
||||
|
||||
@thread = Thread.start { clock { tick } }
|
||||
@thread.abort_on_exception = true
|
||||
@thread.priority = Sidetiq.config.priority
|
||||
|
@ -181,3 +182,4 @@ module Sidetiq
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
3
test/fixtures/simple_worker.rb
vendored
3
test/fixtures/simple_worker.rb
vendored
|
@ -1,4 +1,7 @@
|
|||
class SimpleWorker
|
||||
include Sidekiq::Worker
|
||||
include Sidetiq::Schedulable
|
||||
|
||||
def perform
|
||||
end
|
||||
end
|
||||
|
|
10
test/test_sidetiq.rb
Normal file
10
test/test_sidetiq.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
require_relative 'helper'
|
||||
|
||||
class TestSidetiq < Sidetiq::TestCase
|
||||
def test_schedules
|
||||
assert_equal Sidetiq.schedules, Sidetiq::Clock.schedules
|
||||
assert_equal [ScheduledWorker], Sidetiq.schedules.keys
|
||||
assert_kind_of Sidetiq::Schedule, Sidetiq.schedules[ScheduledWorker]
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in a new issue