diff --git a/HISTORY.md b/HISTORY.md index 28f8ce63..9dcda046 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,12 @@ +## 1.0.5 (2010-03-01) + +* Fixed support for overriding queue from schedule config. +* Removed resque-web dependency on loading the job classes for "Queue Now", + provided "queue" is specified in the schedule. +* The queue is now stored with the job and arguments in the delayed queue so + there is no longer a need for the scheduler to load job classes to introspect + the queue. + ## 1.0.4 (2010-02-26) * Added support for specifying the queue to put the job onto. This allows for diff --git a/README.markdown b/README.markdown index def9a301..d08a9108 100644 --- a/README.markdown +++ b/README.markdown @@ -37,7 +37,7 @@ 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 + queue: scoring args: moderators description: "This job resets the weekly leaderboard for moderators" diff --git a/lib/resque/scheduler.rb b/lib/resque/scheduler.rb index 9c18960d..7fa0c72d 100644 --- a/lib/resque/scheduler.rb +++ b/lib/resque/scheduler.rb @@ -71,8 +71,8 @@ def handle_delayed_items handle_shutdown do if item = Resque.next_item_for_timestamp(timestamp) log "queuing #{item['class']} [delayed]" - klass = constantize(item['class']) - Resque.enqueue(klass, *item['args']) + queue = item['queue'] || queue_from_class(constantize(item['class'])) + Job.create(queue, item['class'], *item['args']) end end # continue processing until there are no more ready items in this timestamp diff --git a/lib/resque_scheduler.rb b/lib/resque_scheduler.rb index b329c457..0c41b83f 100644 --- a/lib/resque_scheduler.rb +++ b/lib/resque_scheduler.rb @@ -38,7 +38,7 @@ def schedule # for queueing. Until timestamp is in the past, the job will # sit in the schedule list. def enqueue_at(timestamp, klass, *args) - delayed_push(timestamp, :class => klass.to_s, :args => args) + delayed_push(timestamp, :class => klass.to_s, :args => args, :queue => queue_from_class(klass)) end # Identical to enqueue_at but takes number_of_seconds_from_now diff --git a/lib/resque_scheduler/version.rb b/lib/resque_scheduler/version.rb index ff6f7849..2e851a51 100644 --- a/lib/resque_scheduler/version.rb +++ b/lib/resque_scheduler/version.rb @@ -1,3 +1,3 @@ module ResqueScheduler - Version = '1.0.4' + Version = '1.0.5' end diff --git a/test/delayed_queue_test.rb b/test/delayed_queue_test.rb index 1b8e6137..e9dc47eb 100644 --- a/test/delayed_queue_test.rb +++ b/test/delayed_queue_test.rb @@ -98,7 +98,7 @@ def test_delayed_timestamp_peek assert_equal(1, Resque.delayed_timestamp_peek(t, 0, 1).length) assert_equal(2, Resque.delayed_timestamp_peek(t, 0, 3).length) - assert_equal({'args' => [], 'class' => 'SomeIvarJob'}, Resque.delayed_timestamp_peek(t, 0, 1).first) + assert_equal({'args' => [], 'class' => 'SomeIvarJob', 'queue' => 'ivar'}, Resque.delayed_timestamp_peek(t, 0, 1).first) end def test_handle_delayed_items_with_no_items @@ -110,7 +110,10 @@ def test_handle_delayed_items_with_items t = Time.now - 60 # in the past Resque.enqueue_at(t, SomeIvarJob) Resque.enqueue_at(t, SomeIvarJob) - Resque.expects(:enqueue).twice + + # 2 SomeIvarJob jobs should be created in the "ivar" queue + Resque::Job.expects(:create).twice.with('ivar', 'SomeIvarJob') + Resque::Scheduler.expects(:queue_from_class).never # Should NOT need to load the class Resque::Scheduler.handle_delayed_items end