resque-scheduler 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.md +9 -0
- data/README.markdown +1 -1
- data/lib/resque/scheduler.rb +2 -2
- data/lib/resque_scheduler.rb +1 -1
- data/lib/resque_scheduler/version.rb +1 -1
- data/test/delayed_queue_test.rb +5 -2
- metadata +1 -1
data/HISTORY.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## 1.0.5 (2010-03-01)
|
2
|
+
|
3
|
+
* Fixed support for overriding queue from schedule config.
|
4
|
+
* Removed resque-web dependency on loading the job classes for "Queue Now",
|
5
|
+
provided "queue" is specified in the schedule.
|
6
|
+
* The queue is now stored with the job and arguments in the delayed queue so
|
7
|
+
there is no longer a need for the scheduler to load job classes to introspect
|
8
|
+
the queue.
|
9
|
+
|
1
10
|
## 1.0.4 (2010-02-26)
|
2
11
|
|
3
12
|
* Added support for specifying the queue to put the job onto. This allows for
|
data/README.markdown
CHANGED
@@ -37,7 +37,7 @@ queue is given it is not necessary for the scheduler to load the class.
|
|
37
37
|
clear_leaderboards_moderator:
|
38
38
|
cron: "30 6 * * 1"
|
39
39
|
class: ClearLeaderboards
|
40
|
-
|
40
|
+
queue: scoring
|
41
41
|
args: moderators
|
42
42
|
description: "This job resets the weekly leaderboard for moderators"
|
43
43
|
|
data/lib/resque/scheduler.rb
CHANGED
@@ -71,8 +71,8 @@ module Resque
|
|
71
71
|
handle_shutdown do
|
72
72
|
if item = Resque.next_item_for_timestamp(timestamp)
|
73
73
|
log "queuing #{item['class']} [delayed]"
|
74
|
-
|
75
|
-
|
74
|
+
queue = item['queue'] || queue_from_class(constantize(item['class']))
|
75
|
+
Job.create(queue, item['class'], *item['args'])
|
76
76
|
end
|
77
77
|
end
|
78
78
|
# continue processing until there are no more ready items in this timestamp
|
data/lib/resque_scheduler.rb
CHANGED
@@ -38,7 +38,7 @@ module ResqueScheduler
|
|
38
38
|
# for queueing. Until timestamp is in the past, the job will
|
39
39
|
# sit in the schedule list.
|
40
40
|
def enqueue_at(timestamp, klass, *args)
|
41
|
-
delayed_push(timestamp, :class => klass.to_s, :args => args)
|
41
|
+
delayed_push(timestamp, :class => klass.to_s, :args => args, :queue => queue_from_class(klass))
|
42
42
|
end
|
43
43
|
|
44
44
|
# Identical to enqueue_at but takes number_of_seconds_from_now
|
data/test/delayed_queue_test.rb
CHANGED
@@ -98,7 +98,7 @@ class Resque::DelayedQueueTest < Test::Unit::TestCase
|
|
98
98
|
assert_equal(1, Resque.delayed_timestamp_peek(t, 0, 1).length)
|
99
99
|
assert_equal(2, Resque.delayed_timestamp_peek(t, 0, 3).length)
|
100
100
|
|
101
|
-
assert_equal({'args' => [], 'class' => 'SomeIvarJob'}, Resque.delayed_timestamp_peek(t, 0, 1).first)
|
101
|
+
assert_equal({'args' => [], 'class' => 'SomeIvarJob', 'queue' => 'ivar'}, Resque.delayed_timestamp_peek(t, 0, 1).first)
|
102
102
|
end
|
103
103
|
|
104
104
|
def test_handle_delayed_items_with_no_items
|
@@ -110,7 +110,10 @@ class Resque::DelayedQueueTest < Test::Unit::TestCase
|
|
110
110
|
t = Time.now - 60 # in the past
|
111
111
|
Resque.enqueue_at(t, SomeIvarJob)
|
112
112
|
Resque.enqueue_at(t, SomeIvarJob)
|
113
|
-
|
113
|
+
|
114
|
+
# 2 SomeIvarJob jobs should be created in the "ivar" queue
|
115
|
+
Resque::Job.expects(:create).twice.with('ivar', 'SomeIvarJob')
|
116
|
+
Resque::Scheduler.expects(:queue_from_class).never # Should NOT need to load the class
|
114
117
|
Resque::Scheduler.handle_delayed_items
|
115
118
|
end
|
116
119
|
|