Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Branch: master
Failed to load latest commit information.
lib remove file leftover from another project
spec need to wrap args in [] to reflect what Resque does
.gitignore ignore my vendor/cache dir
.rvmrc inital setup
Gemfile inital setup
Gemfile.lock update docs
MIT-LICENSE inital setup fix syntax highlighting
Rakefile this check not needed

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.