Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE: Optional handler name column #1058

Open
abrom opened this issue Oct 26, 2018 · 0 comments
Open

FEATURE: Optional handler name column #1058

abrom opened this issue Oct 26, 2018 · 0 comments

Comments

@abrom
Copy link

abrom commented Oct 26, 2018

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..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant