Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Now able to add Jobs to a Queue from the Schedule without having the …

…Job loaded in the process.
  • Loading branch information...
commit 08c9e74c15a28dd6c384fc3edfda411bc59c03fd 1 parent df72e6d
@malomalo malomalo authored bvandenbos committed
View
6 HISTORY.md
@@ -1,3 +1,9 @@
+## 1.0.4 (2010-02-26)
+
+* Added support for specifying the queue to put the job onto. This allows for
+ you to have one job that can go onto multiple queues and be able to schedule
+ jobs without having to load the job classes.
+
## 1.0.3 (2010-02-11)
* Added support for scheduled jobs with empty crons. This is helpful to have
View
15 README.markdown
@@ -1,8 +1,8 @@
resque-scheduler
===============
-Resque-scheduler is an extension to [Resque](http://github.com/defunkt/resque) that adds support for queueing items
-in the future.
+Resque-scheduler is an extension to [Resque](http://github.com/defunkt/resque)
+that adds support for queueing items in the future.
Requires redis >=1.1.
@@ -22,7 +22,7 @@ is most likely stored in a YAML like so:
cron: "0 0 * * *"
class: QueueDocuments
args:
- description: "This job queues all content for indexing in solr
+ description: "This job queues all content for indexing in solr"
clear_leaderboards_contributors:
cron: "30 6 * * 1"
@@ -30,9 +30,14 @@ is most likely stored in a YAML like so:
args: contributors
description: "This job resets the weekly leaderboard for contributions"
+A queue option can also be specified. When job will go onto the specified queue
+if it is available (Even if @queue is specified in the job class). When the
+queue is given it is not necessary for the scheduler to load the class.
+
clear_leaderboards_moderator:
cron: "30 6 * * 1"
class: ClearLeaderboards
+ queue: scoring
args: moderators
description: "This job resets the weekly leaderboard for moderators"
@@ -47,8 +52,8 @@ it will NOT be ran later when the scheduler process is started back up. In that
sense, you can sort of think of the scheduler process as crond. Delayed jobs,
however, are different.
-A big shout out to [rufus-scheduler](http://github.com/jmettraux/rufus-scheduler) for handling the heavy lifting of the
-actual scheduling engine.
+A big shout out to [rufus-scheduler](http://github.com/jmettraux/rufus-scheduler)
+for handling the heavy lifting of the actual scheduling engine.
### Delayed jobs
View
2  Rakefile
@@ -36,7 +36,7 @@ begin
gemspec.authors = ["Ben VandenBos"]
gemspec.version = ResqueScheduler::Version
- gemspec.add_dependency "resque", ">= 1.3.0"
+ gemspec.add_dependency "resque", ">= 1.5.0"
gemspec.add_dependency "rufus-scheduler"
gemspec.add_development_dependency "jeweler"
gemspec.add_development_dependency "mocha"
View
3  lib/resque/scheduler.rb
@@ -93,7 +93,8 @@ def enqueue_from_config(config)
args = config['args'] || config[:args]
klass_name = config['class'] || config[:class]
params = args.nil? ? [] : Array(args)
- Resque.enqueue(constantize(klass_name), *params)
+ queue = config['queue'] || Resque.queue_from_class(constantize(klass_name))
+ Resque::Job.create(queue, klass_name, *params)
end
def rufus_scheduler
View
1  lib/resque_scheduler/server/views/scheduler.erb
@@ -26,6 +26,7 @@
<td><%= h config['description'] %></td>
<td style="white-space:nowrap"><%= h config['cron'] %></td>
<td><%= h config['class'] %></td>
+ <td><%= h config['queue'] || Resque.queue_from_class(constantize(config['class'])) %></td>
<td><%= h config['args'].inspect %></td>
</tr>
<% end %>
View
2  lib/resque_scheduler/version.rb
@@ -1,3 +1,3 @@
module ResqueScheduler
- Version = '1.0.3'
+ Version = '1.0.4'
end
View
7 test/scheduler_test.rb
@@ -6,8 +6,13 @@ def setup
Resque::Scheduler.clear_schedule!
end
+ def test_enqueue_from_config_puts_stuff_in_the_resque_queue_without_class_loaded
+ Resque::Job.stubs(:create).once.returns(true).with('joes_queue', 'BigJoesJob', '/tmp')
+ Resque::Scheduler.enqueue_from_config('cron' => "* * * * *", 'class' => 'BigJoesJob', 'args' => "/tmp", 'queue' => 'joes_queue')
+ end
+
def test_enqueue_from_config_puts_stuff_in_the_resque_queue
- Resque.stubs(:enqueue).once.returns(true).with(SomeIvarJob, '/tmp')
+ Resque::Job.stubs(:create).once.returns(true).with(:ivar, 'SomeIvarJob', '/tmp')
Resque::Scheduler.enqueue_from_config('cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp")
end
Please sign in to comment.
Something went wrong with that request. Please try again.