Skip to content

Instantly share code, notes, and snippets.

@brettbuddin
Created April 23, 2010 16:08
Show Gist options
  • Save brettbuddin/376742 to your computer and use it in GitHub Desktop.
Save brettbuddin/376742 to your computer and use it in GitHub Desktop.
I needed to assign priority dynamically (at the time the job is queued up) with Resque.
class ApplicationJob
def self.set_priority(queue, priority)
if [:high, :medium, :low].include?(priority)
self.instance_eval do
@queue = "#{queue}_#{priority}".to_sym
end
end
end
end
OurJob.set_priority(:our_queue, :high)
Resque.enqueue(OurJob, "Hello world!")
export QUEUE=our_queue_high,our_queue_medium,our_queue_low
# Notice I've left the @queue variable unassigned.
class OurJob < ApplicationJob
def self.perform(str)
puts str
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment