brianjlandau-resque-scheduler 1.10.9 → 1.10.10
Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{brianjlandau-resque-scheduler}
|
8
|
-
s.version = "1.10.
|
8
|
+
s.version = "1.10.10"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ben VandenBos", "Brian Landau"]
|
data/lib/resque/scheduler.rb
CHANGED
@@ -116,13 +116,14 @@ module Resque
|
|
116
116
|
handle_shutdown do
|
117
117
|
if item = Resque.next_item_for_timestamp(timestamp)
|
118
118
|
log "queuing #{item['class']} [delayed]"
|
119
|
-
|
119
|
+
klass = constantize(item['class'])
|
120
|
+
queue = item['queue'] || Resque.queue_from_class(klass)
|
120
121
|
# Support custom job classes like job with status
|
121
122
|
if (job_klass = item['custom_job_class']) && (job_klass != 'Resque::Job')
|
122
123
|
# custom job classes not supporting the same API calls must implement the #schedule method
|
123
124
|
constantize(job_klass).scheduled(queue, item['class'], *item['args'])
|
124
125
|
else
|
125
|
-
Resque::Job.create(queue,
|
126
|
+
Resque::Job.create(queue, klass, *item['args'])
|
126
127
|
end
|
127
128
|
end
|
128
129
|
end
|
@@ -140,14 +141,15 @@ module Resque
|
|
140
141
|
def enqueue_from_config(config)
|
141
142
|
args = config['args'] || config[:args]
|
142
143
|
klass_name = config['class'] || config[:class]
|
144
|
+
klass = constantize(klass_name)
|
143
145
|
params = args.nil? ? [] : Array(args)
|
144
|
-
queue = config['queue'] || config[:queue] || Resque.queue_from_class(
|
146
|
+
queue = config['queue'] || config[:queue] || Resque.queue_from_class(klass)
|
145
147
|
# Support custom job classes like job with status
|
146
148
|
if (job_klass = config['custom_job_class']) && (job_klass != 'Resque::Job')
|
147
149
|
# custom job classes not supporting the same API calls must implement the #schedule method
|
148
150
|
constantize(job_klass).scheduled(queue, klass_name, *params)
|
149
151
|
else
|
150
|
-
Resque::Job.create(queue,
|
152
|
+
Resque::Job.create(queue, klass, *params)
|
151
153
|
end
|
152
154
|
end
|
153
155
|
|
data/test/delayed_queue_test.rb
CHANGED
@@ -116,7 +116,7 @@ class Resque::DelayedQueueTest < Test::Unit::TestCase
|
|
116
116
|
Resque.enqueue_at(t, SomeIvarJob)
|
117
117
|
|
118
118
|
# 2 SomeIvarJob jobs should be created in the "ivar" queue
|
119
|
-
Resque::Job.expects(:create).twice.with('ivar',
|
119
|
+
Resque::Job.expects(:create).twice.with('ivar', SomeIvarJob, nil)
|
120
120
|
Resque.expects(:queue_from_class).never # Should NOT need to load the class
|
121
121
|
Resque::Scheduler.handle_delayed_items
|
122
122
|
end
|
@@ -128,7 +128,7 @@ class Resque::DelayedQueueTest < Test::Unit::TestCase
|
|
128
128
|
Resque.enqueue_at(t, SomeIvarJob)
|
129
129
|
|
130
130
|
# 2 SomeIvarJob jobs should be created in the "ivar" queue
|
131
|
-
Resque::Job.expects(:create).twice.with('ivar',
|
131
|
+
Resque::Job.expects(:create).twice.with('ivar', SomeIvarJob, nil)
|
132
132
|
Resque.expects(:queue_from_class).never # Should NOT need to load the class
|
133
133
|
|
134
134
|
Resque::Scheduler.enqueue_delayed_items_for_timestamp(t)
|
@@ -144,7 +144,7 @@ class Resque::DelayedQueueTest < Test::Unit::TestCase
|
|
144
144
|
# Since we didn't specify :queue when calling delayed_push, it will be forced
|
145
145
|
# to load the class to figure out the queue. This is the upgrade case from 1.0.4
|
146
146
|
# to 1.0.5.
|
147
|
-
Resque::Job.expects(:create).once.with(:ivar,
|
147
|
+
Resque::Job.expects(:create).once.with(:ivar, SomeIvarJob, nil)
|
148
148
|
|
149
149
|
Resque::Scheduler.handle_delayed_items
|
150
150
|
end
|
data/test/scheduler_test.rb
CHANGED
@@ -13,13 +13,8 @@ class Resque::SchedulerTest < Test::Unit::TestCase
|
|
13
13
|
Resque::Scheduler.send(:class_variable_set, :@@scheduled_jobs, {})
|
14
14
|
end
|
15
15
|
|
16
|
-
def test_enqueue_from_config_puts_stuff_in_the_resque_queue_without_class_loaded
|
17
|
-
Resque::Job.stubs(:create).once.returns(true).with('joes_queue', 'BigJoesJob', '/tmp')
|
18
|
-
Resque::Scheduler.enqueue_from_config('cron' => "* * * * *", 'class' => 'BigJoesJob', 'args' => "/tmp", 'queue' => 'joes_queue')
|
19
|
-
end
|
20
|
-
|
21
16
|
def test_enqueue_from_config_puts_stuff_in_the_resque_queue
|
22
|
-
Resque::Job.stubs(:create).once.returns(true).with(:ivar,
|
17
|
+
Resque::Job.stubs(:create).once.returns(true).with(:ivar, SomeIvarJob, '/tmp')
|
23
18
|
Resque::Scheduler.enqueue_from_config('cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp")
|
24
19
|
end
|
25
20
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brianjlandau-resque-scheduler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 43
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 10
|
9
|
-
-
|
10
|
-
version: 1.10.
|
9
|
+
- 10
|
10
|
+
version: 1.10.10
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ben VandenBos
|