QueueClassic/queue_classic

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.

senny commented

@bclennox would #241 suffice for your needs?

That is literally exactly what I want! I just didn't see it while searching issues.

Thanks!

senny commented

😊 thanks for the quick response.

@senny Do you know when this will make it into an official release? I didn't see it on the list for 3.2 in #250, and it's not on the 3-1-stable branch yet.

senny commented

@bclennox it will be part of 3.2