Skip to content


Subversion checkout URL

You can clone with
Download ZIP
branch: master

Simple Resque

I needed a simple way to queue Resque jobs from a web app where the jobs were defined in a separate "worker" codebase, running completely independently from the web app. Unfortunately, Resque requires you to pass the class name of a job as a constant, when what I really needed was to pass a string which would get turned into a constant class name by the worker codebase.

I had to do this enough times that I decided to wrap the idiom in a gem, figuring that over time I'll need to add other simplifications of the Resque API. The gem assumes that the queue name is an underscored version of the class name.


require "resque"
require "simple_resque"
Resque.redis = 'localhost:6379'
SimpleResque.resque = Resque


require 'simple_resque'

# puts a job on the "transmogrifier" queue with class "Transmogrifier" and
# arguments { id: 3, state: "back_to_calvin" }

SimpleResque.push("Transmogrifier",id: 3, state: "back_to_calvin")

# These methods are useful in integration/acceptance tests; if you wanted
# to use these in production you would be better off using Resque the
# conventional way

SimpleResque.size("Transmogrifier") # => 1
SimpleResque.pop("Transmogrifier") # => {"class"=>"Transmogrifier", "args"=>{"id"=>3, "state"=>"back_to_calvin"}}

Problems? Questions?

Email or file an issue on GitHub.

Patches are welcome. Thanks!


See MIT-LICENSE for details.

Something went wrong with that request. Please try again.