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

Add queue attribute run_delay #1003

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

johnnyshields
Copy link

@johnnyshields johnnyshields commented Oct 23, 2017

  • Add queue attribute run_delay which is a default time offset/delay by which to run the job
  • light refactoring to JobPreparer
  • additional specs covering queue attributes from JobPreparer

The use case for this is that I'm using MongoDB and due to how replica set work (non-transnational) there are occasional mailer job failures when objects havent been replicated across all replica sets.

@johnnyshields
Copy link
Author

The spec failure here is not related to this PR, please check travis.

@albus522
Copy link
Member

albus522 commented Jan 29, 2018

This is an interesting idea, but I think you can get the result you want using DJ lifecycle callbacks which are unfortunately not well documented.

Adding something like this in your DJ initializer should do what you want

Delayed::Worker.lifecycle.before(:enqueue) do |job|
  if job.queue == "my queue"
    job.run_at ||= 10.seconds.from_now
  end
end

This also allows you to use other attributes of the job than just the queue name to determine how much you want to delay things.

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

Successfully merging this pull request may close these issues.

None yet

2 participants