delayed_job icon indicating copy to clipboard operation
delayed_job copied to clipboard

FEATURE: Optional handler name column

Open abrom opened this issue 6 years ago • 0 comments

I propose that an optional column be supported that stores the handler (job) name. It looks like it would be a fairly trivial change to the Delayed::Backend::Base module to support this. Likely something along the lines of:

module ClassMethods
  def initialize(*args)
    super(*args)

    if Delayed::Worker.handler_name_column.present? &&
         Delayed::Job.columns_hash.key?(Delayed::Worker.handler_name_column.to_s)
      self[Delayed::Worker.handler_name_column] = name
    end
  end
end 

The code could go in the JobPreparer class, however it could mean some duplication of the name method from the Base module.

I've been using a before enqueue callback to achieve this for some time now, and wondered if a natively supported option would be something the community at large would be interested in.

I use it to speed up queries for finding jobs of the same type; to help with analytics and queue management.

The current alternative would be to use the following query, but it's db heavy and the indexes aren't pretty.

substring(handler from '^--- !ruby/object:(\w+)')

I'm happy to put together a PR..

abrom avatar Oct 26 '18 01:10 abrom