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

Upstream fix for sidekiq 6 5 0 #43

Merged
merged 2 commits into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.7.6
9 changes: 8 additions & 1 deletion lib/sidekiq-rate-limiter/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@
require 'sidekiq-rate-limiter/fetch'

Sidekiq.configure_server do |config|
Sidekiq.options[:fetch] = Sidekiq::RateLimiter::Fetch
# Backwards compatibility for Sidekiq < 6.1.0 (see https://github.com/mperham/sidekiq/pull/4602 for details)
if (Sidekiq::BasicFetch.respond_to?(:bulk_requeue))
Sidekiq.options[:fetch] = Sidekiq::RateLimiter::Fetch
elsif (Sidekiq::VERSION < '6.5.0') # Sidekiq config was redesigned in https://github.com/mperham/sidekiq/pull/5340
Sidekiq.options[:fetch] = Sidekiq::RateLimiter::Fetch.new(Sidekiq.options)
else
Sidekiq[:fetch] = Sidekiq::RateLimiter::Fetch.new(Sidekiq)
end
end
8 changes: 6 additions & 2 deletions spec/sidekiq-rate-limiter/fetch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ def perform(arg1, arg2); end
end
end

let(:options) { { queues: [queue, another_queue, another_queue] } }
let(:options) {
s = Sidekiq
s[:queues] = [queue, another_queue, another_queue]
s
}
let(:queue) { 'basic' }
let(:another_queue) { 'some_other_queue' }
let(:args) { ['I am some args'] }
Expand All @@ -47,7 +51,7 @@ def perform(arg1, arg2); end
Sidekiq::Fetcher::TIMEOUT
end

fetch = described_class.new options.merge(:strict => true)
fetch = described_class.new options.merge!(:strict => true)
expect(fetch.queues_cmd).to eql(["queue:#{queue}", "queue:#{another_queue}", timeout])
end

Expand Down
4 changes: 2 additions & 2 deletions spec/sidekiq-rate-limiter/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

it 'should set Sidekiq.options[:fetch] as desired' do
Sidekiq.configure_server do |config|
expect(Sidekiq.options[:fetch]).to eql(Sidekiq::RateLimiter::Fetch)
expect(Sidekiq.options[:fetch]).to be_a(Sidekiq::RateLimiter::Fetch)
end
end

it 'should inherit from Sidekiq::BasicFetch' do
Sidekiq.configure_server do |config|
expect(Sidekiq.options[:fetch]).to be < Sidekiq::BasicFetch
expect(Sidekiq.options[:fetch].class.ancestors[1]).to be(Sidekiq::BasicFetch)
end
end
end
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'sidekiq'
require 'sidekiq/testing'
require 'pry-byebug'

## Confirming presence of redis server executable
abort "## `redis-server` not in path" if %x(which redis-server).empty?
Expand Down