1
0
Fork 0
mirror of https://github.com/deanpcmad/sidekiq-limit_fetch.git synced 2022-11-09 13:54:36 -05:00

Updates that support Sidekiq 6.5+

Some changes to Sidekiq internals require changes to how we pass
options to certain Sidekiq classes we inherit from. These changes
maintain backwards compatibility, but add some complexity to the
code.
This commit is contained in:
Bobby McDonald 2022-08-16 13:14:31 -04:00
parent 03baa2c9d0
commit 2afeb8b2c2
No known key found for this signature in database
GPG key ID: CAD931A49619329A
2 changed files with 19 additions and 2 deletions

View file

@ -28,13 +28,18 @@ module Sidekiq::LimitFetch
UnitOfWork.new(queue, job) if job
end
def config
# Post 6.5, Sidekiq.options is deprecated and replaced with passing Sidekiq directly
post_6_5? ? Sidekiq : Sidekiq.options
end
# Backwards compatibility for sidekiq v6.1.0
# @see https://github.com/mperham/sidekiq/pull/4602
def bulk_requeue(*args)
if Sidekiq::BasicFetch.respond_to?(:bulk_requeue) # < 6.1.0
Sidekiq::BasicFetch.bulk_requeue(*args)
else # 6.1.0+
Sidekiq::BasicFetch.new(Sidekiq.options).bulk_requeue(*args)
Sidekiq::BasicFetch.new(config).bulk_requeue(*args)
end
end
@ -56,6 +61,10 @@ module Sidekiq::LimitFetch
private
def post_6_5?
@post_6_5 ||= Gem::Version.new(Sidekiq::VERSION) >= Gem::Version.new('6.5.0')
end
def redis_brpop(queues)
if queues.empty?
sleep TIMEOUT # there are no queues to handle, so lets sleep

View file

@ -1,7 +1,11 @@
module Sidekiq
class LimitFetch::UnitOfWork < BasicFetch::UnitOfWork
def initialize(queue, job)
super
if post_6_5?
super(queue, job, Sidekiq)
else
super
end
redis_retryable { Queue[queue_name].increase_busy }
end
@ -17,6 +21,10 @@ module Sidekiq
private
def post_6_5?
Gem::Version.new(Sidekiq::VERSION) >= Gem::Version.new('6.5.0')
end
def redis_retryable(&block)
Sidekiq::LimitFetch.redis_retryable(&block)
end