resque-scheduler 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.md +6 -0
- data/README.markdown +11 -6
- data/Rakefile +1 -1
- data/lib/resque/scheduler.rb +3 -2
- data/lib/resque_scheduler/server.rb +4 -0
- data/lib/resque_scheduler/server/views/scheduler.erb +2 -0
- data/lib/resque_scheduler/version.rb +1 -1
- data/test/scheduler_test.rb +6 -1
- metadata +3 -3
data/HISTORY.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 1.0.4 (2010-02-26)
|
2
|
+
|
3
|
+
* Added support for specifying the queue to put the job onto. This allows for
|
4
|
+
you to have one job that can go onto multiple queues and be able to schedule
|
5
|
+
jobs without having to load the job classes.
|
6
|
+
|
1
7
|
## 1.0.3 (2010-02-11)
|
2
8
|
|
3
9
|
* Added support for scheduled jobs with empty crons. This is helpful to have
|
data/README.markdown
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
resque-scheduler
|
2
2
|
===============
|
3
3
|
|
4
|
-
Resque-scheduler is an extension to [Resque](http://github.com/defunkt/resque)
|
5
|
-
in the future.
|
4
|
+
Resque-scheduler is an extension to [Resque](http://github.com/defunkt/resque)
|
5
|
+
that adds support for queueing items in the future.
|
6
6
|
|
7
7
|
Requires redis >=1.1.
|
8
8
|
|
@@ -22,7 +22,7 @@ is most likely stored in a YAML like so:
|
|
22
22
|
cron: "0 0 * * *"
|
23
23
|
class: QueueDocuments
|
24
24
|
args:
|
25
|
-
description: "This job queues all content for indexing in solr
|
25
|
+
description: "This job queues all content for indexing in solr"
|
26
26
|
|
27
27
|
clear_leaderboards_contributors:
|
28
28
|
cron: "30 6 * * 1"
|
@@ -30,9 +30,14 @@ is most likely stored in a YAML like so:
|
|
30
30
|
args: contributors
|
31
31
|
description: "This job resets the weekly leaderboard for contributions"
|
32
32
|
|
33
|
+
A queue option can also be specified. When job will go onto the specified queue
|
34
|
+
if it is available (Even if @queue is specified in the job class). When the
|
35
|
+
queue is given it is not necessary for the scheduler to load the class.
|
36
|
+
|
33
37
|
clear_leaderboards_moderator:
|
34
38
|
cron: "30 6 * * 1"
|
35
39
|
class: ClearLeaderboards
|
40
|
+
queue: scoring
|
36
41
|
args: moderators
|
37
42
|
description: "This job resets the weekly leaderboard for moderators"
|
38
43
|
|
@@ -47,8 +52,8 @@ it will NOT be ran later when the scheduler process is started back up. In that
|
|
47
52
|
sense, you can sort of think of the scheduler process as crond. Delayed jobs,
|
48
53
|
however, are different.
|
49
54
|
|
50
|
-
A big shout out to [rufus-scheduler](http://github.com/jmettraux/rufus-scheduler)
|
51
|
-
actual scheduling engine.
|
55
|
+
A big shout out to [rufus-scheduler](http://github.com/jmettraux/rufus-scheduler)
|
56
|
+
for handling the heavy lifting of the actual scheduling engine.
|
52
57
|
|
53
58
|
### Delayed jobs
|
54
59
|
|
@@ -114,7 +119,7 @@ The scheduler process is just a rake task which is responsible for both queueing
|
|
114
119
|
items from the schedule and polling the delayed queue for items ready to be
|
115
120
|
pushed on to the work queues. For obvious reasons, this process never exits.
|
116
121
|
|
117
|
-
$ rake resque
|
122
|
+
$ rake resque:scheduler
|
118
123
|
|
119
124
|
Supported environment variables are `VERBOSE` and `MUTE`. If either is set to
|
120
125
|
any nonempty value, they will take effect. `VERBOSE` simply dumps more output
|
data/Rakefile
CHANGED
@@ -36,7 +36,7 @@ begin
|
|
36
36
|
gemspec.authors = ["Ben VandenBos"]
|
37
37
|
gemspec.version = ResqueScheduler::Version
|
38
38
|
|
39
|
-
gemspec.add_dependency "resque", ">= 1.
|
39
|
+
gemspec.add_dependency "resque", ">= 1.5.0"
|
40
40
|
gemspec.add_dependency "rufus-scheduler"
|
41
41
|
gemspec.add_development_dependency "jeweler"
|
42
42
|
gemspec.add_development_dependency "mocha"
|
data/lib/resque/scheduler.rb
CHANGED
@@ -56,7 +56,7 @@ module Resque
|
|
56
56
|
enqueue_from_config(config)
|
57
57
|
end
|
58
58
|
else
|
59
|
-
log! "
|
59
|
+
log! "no cron found for #{config['class']} (#{name}) - skipping"
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
@@ -93,7 +93,8 @@ module Resque
|
|
93
93
|
args = config['args'] || config[:args]
|
94
94
|
klass_name = config['class'] || config[:class]
|
95
95
|
params = args.nil? ? [] : Array(args)
|
96
|
-
Resque.
|
96
|
+
queue = config['queue'] || config[:queue] || Resque.queue_from_class(constantize(klass_name))
|
97
|
+
Resque::Job.create(queue, klass_name, *params)
|
97
98
|
end
|
98
99
|
|
99
100
|
def rufus_scheduler
|
@@ -12,6 +12,7 @@
|
|
12
12
|
<th>Description</th>
|
13
13
|
<th>Cron</th>
|
14
14
|
<th>Class</th>
|
15
|
+
<th>Queue</th>
|
15
16
|
<th>Arguments</th>
|
16
17
|
</tr>
|
17
18
|
<% Resque.schedule.each do |name, config| %>
|
@@ -26,6 +27,7 @@
|
|
26
27
|
<td><%= h config['description'] %></td>
|
27
28
|
<td style="white-space:nowrap"><%= h config['cron'] %></td>
|
28
29
|
<td><%= h config['class'] %></td>
|
30
|
+
<td><%= h config['queue'] || queue_from_class_name(config['class']) %></td>
|
29
31
|
<td><%= h config['args'].inspect %></td>
|
30
32
|
</tr>
|
31
33
|
<% end %>
|
data/test/scheduler_test.rb
CHANGED
@@ -6,8 +6,13 @@ class Resque::SchedulerTest < Test::Unit::TestCase
|
|
6
6
|
Resque::Scheduler.clear_schedule!
|
7
7
|
end
|
8
8
|
|
9
|
+
def test_enqueue_from_config_puts_stuff_in_the_resque_queue_without_class_loaded
|
10
|
+
Resque::Job.stubs(:create).once.returns(true).with('joes_queue', 'BigJoesJob', '/tmp')
|
11
|
+
Resque::Scheduler.enqueue_from_config('cron' => "* * * * *", 'class' => 'BigJoesJob', 'args' => "/tmp", 'queue' => 'joes_queue')
|
12
|
+
end
|
13
|
+
|
9
14
|
def test_enqueue_from_config_puts_stuff_in_the_resque_queue
|
10
|
-
Resque.stubs(:
|
15
|
+
Resque::Job.stubs(:create).once.returns(true).with(:ivar, 'SomeIvarJob', '/tmp')
|
11
16
|
Resque::Scheduler.enqueue_from_config('cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp")
|
12
17
|
end
|
13
18
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque-scheduler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben VandenBos
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-03-01 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 1.
|
23
|
+
version: 1.5.0
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rufus-scheduler
|