-
-
Save jrochkind/6be2cd72161fc9bebf3b3f8ec3e3f226 to your computer and use it in GitHub Desktop.
patch Rails resque adapter to be willing to enqueue_at NOW
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# monkey patch resque adapter to be willing to enqueue_at NOW, | |
# to let us use ActiveJob retry_on with wait: 0. Resque | |
# can't enqueue in the future without resque-scheduler, | |
# but we can enqueue at wait:0/NOW. | |
module AllowResqueEnqueueAtNow | |
def enqueue_at(job, timestamp) #:nodoc:de | |
if !Resque.respond_to?(:enqueue_at_with_queue) && timestamp.to_i <= Time.now.to_i | |
# we don't have resque-scheduler, but it's asking for it to run RIGHT NOW anyway, | |
# just enqueue as usual. | |
enqueue(job) | |
else | |
super | |
end | |
end | |
end | |
ActiveJob::QueueAdapters::ResqueAdapter.prepend(AllowResqueEnqueueAtNow) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment