-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
when retrieving queue name, check for 'queue_name' which is how ActiveJob defines queue names #1713
base: master
Are you sure you want to change the base?
Conversation
But either way, Resque should not know anything about Active Job. Why do you think this change is necessary? The Active Job adapter already set the correct queue name to Resque. https://github.com/rails/rails/blob/855c9897eb98ea4d77ec5036d15cdd1764698838/activejob/lib/active_job/queue_adapters/resque_adapter.rb#L33 |
…ob defines queue names
3a4994b
to
b47c015
Compare
Branch updated to use I needed this to allow resque-scheduler to correctly queue ActiveJobs: https://github.com/resque/resque-scheduler/blob/master/lib/resque/scheduler/server.rb#L149 - that plugin uses I suspect this fix is probably still necessary in this context given that |
Yea, I think the issue (which has nothing to do with resque-scheudler) is that
|
That makes sense. That happen because resque doesn't, and should not, know about Active Job. So Also, we can't determine the queue name for a subclass of That being said, in order to expose the queue for a job we will need to make significant changes to the Resque plugin in Active Job to wrap each job in a class like we do in the Sidekiq adapter. |
This PR is doing: Apologies, but I'm not sure I follow what you are saying here:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@josh-m-sharpe Although I agree with rafaelfranca in principle—that resque shouldn't know about ActiveJob—I think it's a better UX to add some light bindings / support for ActiveJob given that's a very popular pattern.
@rafaelfranca Could you explain further why "we will need to make significant changes to the Resque plugin in Active Job"? I'm not seeing any issues here, but I don't have as much experience with ActiveJob.
(klass.respond_to?(:queue) and klass.queue) | ||
klass.instance_variable_get(:@queue) || | ||
(klass.respond_to?(:queue) && klass.queue) || | ||
(klass.respond_to?(:queue_name) && klass.new.queue_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could add more inline documentation here about what cases these different lines are handling? Even just a link to this PR in code would be helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@josh-m-sharpe quick reminder here! Would love to tidy up this PR and get it merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to tidy it up and get it merged!
This fixes an issue when queueing jobs from resque-scheduler's Scheudle page. Without this change, resque is unable to identify the queue to drop the job on.
ActiveJob details:
https://api.rubyonrails.org/classes/ActiveJob/QueueName/ClassMethods.html#method-i-queue_as
https://github.com/rails/rails/blob/157920aead96865e3135f496c09ace607d5620dc/activejob/lib/active_job/queue_name.rb#L41
https://github.com/rails/rails/blob/157920aead96865e3135f496c09ace607d5620dc/activejob/lib/active_job/queue_name.rb#L62