Backgrounded: A Simple Wrapper for Ruby Background Tasks
Like Ryan Sonnek, I've dabbled with a few different ways to run background processes in my Ruby apps, even resorting to knocking together my own (far from perfect) solution. As Ryan says on his blog, many popular libraries have complicated interfaces and don't "feel right".
I tend to disagree, however, with his statement that every ruby background job solution sucks, and I'm sure he doesn't really mean it. Although his offering, Backgrounded, is refreshingly simple and concise, it's effectively just a wrapper for other solutions.
With Backgrounded, if you want a certain method to always run in the background, you can specify it like this:
class User backgrounded :do_stuff def do_stuff # do all your work here end end
...and then just call that method in the normal way. The actual background work can be taken care of by a handler of your choice, but delayed_job comes bundled.
Ryan's meta-programming approach for declaring background tasks doubles-up as documentation, and puts the focus on the individual methods rather than requiring you to create separate classes for your jobs.
Get Backgrounded as a gem or download the source from Github.