Skip to content
No description or website provided.
Ruby
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
spec
.gitignore
.rvmrc
Gemfile
Gemfile.lock
Guardfile
MIT-LICENSE
README.md
Rakefile
simple_resque.gemspec

README.md

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.

Setup

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

Usage

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"}}
SimpleResque.clear("Transmogrifier")

Problems? Questions?

Email mike@subelsky.com or file an issue on GitHub.

Patches are welcome. Thanks!

License

See MIT-LICENSE for details.

Something went wrong with that request. Please try again.