Permalink
Browse files

Add a queue lookup to allow fast-tracking.

also now more functional when caching is on.
  • Loading branch information...
jdwyah committed Jun 22, 2012
1 parent f7a87f0 commit 5d94568d9e62bc501bfaf7c85f9b5b0e4050ffc4
Showing with 13 additions and 4 deletions.
  1. +1 −1 lib/patella.rb
  2. +11 −3 lib/patella/send_later_worker.rb
  3. +1 −0 patella.gemspec
View
@@ -4,5 +4,5 @@
require "patella/send_later_worker"
module Patella
- # Your code goes here...
+ ActiveRecord::Base.send :include, ::Patella::SendLater
end
@@ -1,9 +1,17 @@
module Patella
class SendLaterWorker
- @queue = :send_later
+ extend ::Resque::Plugins::Meta
+ @@default_queue = :send_later
+ @@queues = {}
- def self.perform_later *args
- self.enqueue *args
+ def self.perform_later(*args)
+ # args[0] is class name of invoking class, args[2] is method
+ queue = self.queue_for(args[0], args[2])
+ Resque::Job.create(queue, 'Patella::SendLaterWorker', *args)
+ end
+
+ def self.queue_for(class_name, method_name)
+ @@queues[class_name].try(:[],method_name) || @@default_queue
end
def self.perform(class_name, instance_id, method_name, *args)
View
@@ -15,6 +15,7 @@ Gem::Specification.new do |gem|
gem.require_paths = ["lib"]
gem.version = Patella::VERSION
gem.add_dependency 'resque', '~>1.16'
+ gem.add_dependency 'resque-meta', '~>1.0.0'
gem.add_dependency 'activesupport', '~>2.3' #, :require => 'active_support'
gem.add_dependency 'rails', '~>2.3' #, :require => 'active_support'
gem.add_dependency 'json'

0 comments on commit 5d94568

Please sign in to comment.