Delayed Job hits 3.0; Marston on Deprecating Legacy Code
published Thursday, January 12, 2012
Delayed Job went 3.0 recently with two major changes: named queues and callbacks on the lifecycle of a job. They also changed it so that the ActiveRecord backend is provided by a gem, which means one could provide another backend if they were so inclined.
I think the named queues are the only thing I'd use. This could give you a way to segment jobs and assign a different number of workers based on the importance of the jobs. Maybe you'd have a "normal" queue and an "important" queue and have more workers per job on the important one. Looks easy to use:
object.delay(:queue => 'important').method
Then if you're using rake to work your jobs, just start your worker like this:
$ QUEUE=important rake jobs:work
They also fixed a couple bugs, but none of them were familiar to me.
Really excellent write-up of Myron Marston's experience refactoring some legacy code. He gives us some great insight into the techniques they used, which were totally new to me. I love this idea that you could add a field to your user indicating if they should be using the old or new code and then the surprisingly few places in Rails where they needed to use this flag. Very clean and organized.