-
Notifications
You must be signed in to change notification settings - Fork 956
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
Queue priority in config #845
Queue priority in config #845
Conversation
Can you please rebase from master and fix the outstanding RuboCop style guide violations in your code? |
I have rebased from master ... I hope I have done it correctly. Let me know if there is anything I need to fix. There were also a couple of rubocop issues that weren't mine which I included as well. |
@ryannealmes This doesn’t look quite right. Try this in your fork:
Also, ideally all of the changes in your branch would be squashed into a single commit. Let me know if you need instructions on how to do that. |
d43cbcc
to
c3cc9da
Compare
Cool, I think I am there. Let me know what you think. Thanks for the help. |
Hey @sferik, is there anything I need to do to get this merged? I know guys are probably pretty busy with other stuff, but I am not really sure if I should just wait until someone says something or if I should actively be chatting to someone. Thanks. |
@ryannealmes Thanks for this PR, this is really a crucial bit! (I have to up an app to Rails 4.2 now and without this feature, I'll be forced to switch to another backend.) @sferik Any chance this will be merged soonish? |
@@ -4,7 +4,7 @@ Gem::Specification.new do |spec| | |||
spec.description = 'Delayed_job (or DJ) encapsulates the common pattern of asynchronously executing longer tasks in the background. It is a direct extraction from Shopify where the job table is responsible for a multitude of core tasks.' | |||
spec.email = ['brian@collectiveidea.com'] | |||
spec.files = %w[CHANGELOG.md CONTRIBUTING.md LICENSE.md README.md Rakefile delayed_job.gemspec] | |||
spec.files += Dir.glob('{contrib,lib,recipes,spec}/**/*') | |||
spec.files += Dir.glob('{contrib,lib,recipes,spec}/**/*') # rubocop:disable SpaceAroundOperators</code> |
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.
Should this have </code>
at the end?
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.
Also, just one space after rubocop:disable
.
Sorry for the long delay on merging this pull request. Other than the few minor questions/suggestions I just made related to RuboCop, this looks good to me. I’d like to merge this and release it at the same time as Rails 5 compatibility. Of course, Rails 5 is not yet released but I’m hoping it will come later this year or early 2016. In the mean time, after this is merged, you’ll be able to use it by specifying a Git source in your gem 'delayed_job', :git => 'https://github.com/collectiveidea/delayed_job.git' |
There might still be a problem lurking. With the version from the queue-priority-in-config branch of ryannealmes/delayed_job, I experience the following behaviour:
|
I found the cause for the problem mentioned in my previous comment. While the ActiveJob documentation uses symbols for queue names, the actual queue name is converted to a string internally. Therefore, when setting default priorities per queue, you must currently use a string to reference the queue. Now, I won't be the only one tripping over this 😄 I suggest adding a Delayed::Backend::JobPreparer#set_priority:
|
@ryannealmes I've added a PR to your fork with this fix and a little addition to the README explaining your feature. The rubocop directive cleanup suggested by @sferik is also included: ryannealmes#2 |
…r to pull from worker prior to setting job priority to default priority.
09efe0a
to
3f198bc
Compare
Looks good to me! Thanks for the patch! |
@ryannealmes No idea, after all, collectiveidea/delayed_job is listed as a repo you've contributed to. Maybe a Github glitch. |
@svoop I was looking forward to being a contributor :/ At least the functionality is there now :) |
Maybe it uses the timestamp of the commit, and the public activity thing doesn't scroll back to September |
@ryannealmes It’s because this is a fork and GitHub only counts contributions to the original repo. |
Any chance of getting a release with this change before all of the rails 5 stuff @sferik? |
We already have the rails 5 stuff in master. I don't like releasing something against in flux dependencies. Have been bitten by that too much. |
fair enough. I wonder if I'm missing a simple way to get what I want anyway without risking the bleeding edge. Is there a way to set the priority with a rails4 mailer? something like:
I know that activeMailer supports queues - so default queue priorities will allow
|
Be aware I have simplified the configuration structure on this in master and the about to be released gem |
Queue priority is not settable via a config file. This causes complications when you want to set queue priority and leverage ActiveJob in Rails. In order to allow setting queue priority I have created a queue_attributes attribute that falls off the worker. The attribute is then accessed and the priority is set when setting up the job prior to enqueuing.
I have extracted the enqueueing code into it's own class to try and clean things up a little into a
JobPreparer
for a lack of a better name.Some side notes it may be better to rather use the
queue
attribute on the worker, but I thought this was a good start.This is my first public PR to someone else's repo. I have read the guidelines ... I am happy if it's rejected, but input on where I can improve in future or how I can change things to provide similar functionality would be much appreciated.
Someone also started a thread requesting this functionality.