Small plugin appending the calling worker to the argument list received by the perform method of Resque jobs. Developed against Resque 1.8.0.
Purpose: this allows jobs to access shared sockets in the parent worker.
Be careful to note that each job forks before running, so ivars will be a COPY and, if changed, their changes won't persist into the next job's perform method. However, since sockets ARE persisted, this allows multiple jobs to share a single persistent socket kept alive in the worker.
Only running in certain workers
As additional functionality, this plugin can also abort a job gracefully if it's picked up by the wrong worker class, which is useful if you've subclassed Resque::Worker to add your own functionality and need to ensure your jobs aren't accidentally run against the original superclass.
To use, add
to the class with the perform method.
To implement the additional requiring-certain-worker-class feature, add
self.required_worker_class = 'ClassName'
Copyright © 2010 Kali Donovan. See LICENSE for details.