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

Gem not working through perform_later due to ActiveJob's ResqueAdapter overriding klass with JobWrapper? #20

Open
panagspirou opened this issue Jan 21, 2022 · 0 comments

Comments

@panagspirou
Copy link

Hey!

Suppose we have a class MyJob, inheriting from ApplicationJob:

class MyJob < ApplicationJob
  include Resque::Plugins::UniqueJob
  ...
  ...
  def perform(object_id)
    ..
  end
end

By doing:

Resque.enqueue MyJob, object_id

we bypass the middle things happening inside ActiveJob framework and we call directly Resque.enqueue, which has been overriden by this gem, so the work of scheduling unique jobs is done fine.

However, when scheduling a background job through the common perform_later

MyJob.perform_later(object_id)

then this goes through ActiveJob framework, which will be utilizing the corresponding ResqueAdapter, which in turn triggers Resque.enqueue but with klass set to JobWrapper
https://github.com/rails/rails/blob/main/activejob/lib/active_job/queue_adapters/resque_adapter.rb#L31-L34

To my understanding, this unfortunately makes then the is_unique? check done by this gem to be always failing because that JobWrapper class will not have the ::Resque::Plugins::UniqueJob included, thus not adhering to create unique jobs.

def is_unique?(item)
const_for(item).included_modules.include?(::Resque::Plugins::UniqueJob)
rescue NameError
false
end

Do I miss something obvious?
If yes, what?
If not, are there any suggestions to overcome this?

Thanks a lot in advance!

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