Simpler support for custom worker class
Closed this issue · 5 comments
Currently, in order to create a custom exception handler, you need to create a subclass of QC::Worker
and override the #handle_failure
method. In addition, you also have to create a custom Rake task to trap INT and TERM and call out to an instance of your custom worker.
The first step makes a lot of sense, but the second step seems unnecessary. It would be simpler for users if there were an API like this:
# lib/my_worker.rb
class MyWorker < QC::Worker
def handle_failure(job, e)
# ...
end
end
QC.worker_class = MyWorker
This is based on the unfounded assumption that it's much more common to change how exceptions are handled than how signals are handled, so it would be valuable to make the first case simpler.
I'm happy to contribute a PR if this is a feature that you guys want.
That is literally exactly what I want! I just didn't see it while searching issues.
Thanks!
😊 thanks for the quick response.