1
0
Fork 0
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:
Tobias Svensson 2013-03-11 12:24:11 +00:00
parent d4b7761dde
commit 5058048ae3
4 changed files with 23 additions and 2 deletions

View file

@ -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

View file

@ -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

View file

@ -1,4 +1,7 @@
class SimpleWorker
include Sidekiq::Worker
include Sidetiq::Schedulable
def perform
end
end

10
test/test_sidetiq.rb Normal file
View 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