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

V3: Drop support for sidekiq 6.x and ruby 2.7 #28

Merged
merged 1 commit into from
Oct 15, 2024
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
5 changes: 0 additions & 5 deletions .github/gemfiles/sidekiq-6.5.12.gemfile

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
strategy:
fail-fast: false
matrix:
sidekiq: [ "6.5.12", "7.2.3" ]
ruby: [ "2.7.7", "3.0.6", "3.1.4", "3.2.4", "3.3.1" ]
redis: [ "6.2-alpine", "7.2-alpine" ]
sidekiq: [ "7.2.3" ]
ruby: [ "3.0.6", "3.1.4", "3.2.4", "3.3.1" ]
redis: [ "7.2-alpine" ]
env:
RAILS_ENV: test
SIDEKIQ_VERSION: ${{ matrix.sidekiq }}
Expand Down
17 changes: 2 additions & 15 deletions lib/sidekiq/debouncer/enq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,8 @@ class Enq < ::Sidekiq::Scheduled::Enq
define_lua_command(:zpopbyscore_withscore, LUA_ZPOPBYSCORE_WITHSCORE)
define_lua_command(:zpopbyscore_multi, LUA_ZPOPBYSCORE_MULTI)

def initialize(config)
if Gem::Version.new(Sidekiq::VERSION) < Gem::Version.new("7.0.0")
super()
@client = Sidekiq::Client
@redis = Sidekiq.method(:redis)
@logger = Sidekiq.logger
else
super(config)
@redis = config.method(:redis)
@logger = config.logger
end
end

def enqueue_jobs
@redis.call do |conn|
redis do |conn|
while !@done && (job, score = zpopbyscore_withscore(conn, [Sidekiq::Debouncer::SET], [Time.now.to_f.to_s]))
job_args = zpopbyscore_multi(conn, [job], [score])

Expand All @@ -37,7 +24,7 @@ def enqueue_jobs

@client.push({"args" => final_args, "class" => klass, "debounce_key" => job})

@logger.debug { "enqueued #{Sidekiq::Debouncer::SET}: #{job}" }
logger.debug { "enqueued #{Sidekiq::Debouncer::SET}: #{job}" }
end
end
end
Expand Down
4 changes: 1 addition & 3 deletions lib/sidekiq/debouncer/lua_commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
module Sidekiq
module Debouncer
module LuaCommands
REDIS_ERROR_CLASS = defined?(RedisClient::CommandError) ? RedisClient::CommandError : Redis::CommandError

def define_lua_command(command, script)
sha = Digest::SHA1.hexdigest(script)
define_method(command) do |conn, keys, argv|
retryable = true
begin
conn.call("EVALSHA", sha, keys.size, *keys, *argv)
rescue REDIS_ERROR_CLASS => e
rescue RedisClient::CommandError => e
raise if !e.message.start_with?("NOSCRIPT") || !retryable

# upload script to redis cache and retry
Expand Down
4 changes: 2 additions & 2 deletions sidekiq-debouncer.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Gem::Specification.new do |gem|
DESCRIPTION
gem.homepage = "https://github.com/paladinsoftware/sidekiq-debouncer"
gem.license = "MIT"
gem.required_ruby_version = ">= 2.7.0"
gem.required_ruby_version = ">= 3.0.0"

gem.files = Dir.glob("lib/**/*") + [
"CHANGELOG.md",
Expand All @@ -27,7 +27,7 @@ Gem::Specification.new do |gem|
"sidekiq-debouncer.gemspec"
]

gem.add_dependency "sidekiq", ">= 6.5", "< 8.0"
gem.add_dependency "sidekiq", ">= 7.0", "< 8.0"

gem.add_development_dependency "rspec", "~> 3.12.0"
gem.add_development_dependency "timecop", "~> 0.9.6"
Expand Down
7 changes: 1 addition & 6 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@
add_filter "/spec/"
end

sidekiq_version = Gem::Version.new(Sidekiq::VERSION)
if sidekiq_version >= Gem::Version.new("7.0")
Sidekiq.default_configuration.logger.level = Logger::UNKNOWN
else
Sidekiq.logger.level = Logger::UNKNOWN
end
Sidekiq.default_configuration.logger.level = Logger::UNKNOWN

Sidekiq::Testing.disable!
Sidekiq::Testing.server_middleware do |chain|
Expand Down
20 changes: 3 additions & 17 deletions spec/support/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,15 @@
shared_context "sidekiq" do
let(:time_start) { Time.new(2016, 1, 1, 12, 0, 0, 0) }
let(:sidekiq_config) do
sidekiq_version = Gem::Version.new(Sidekiq::VERSION)
if sidekiq_version >= Gem::Version.new("7.0")
Sidekiq.default_configuration.tap do |config|
config.queues = ["default", "sample_queue"]
end
else
Sidekiq.queues = ["default", "sample_queue"]
Sidekiq[:fetch] = Sidekiq::BasicFetch.new(Sidekiq)
Sidekiq
Sidekiq.default_configuration.tap do |config|
config.queues = ["default", "sample_queue"]
end
end
let(:queue) { Sidekiq::Queue.new("default") }
let(:sample_queue) { Sidekiq::Queue.new("sample_queue") }
let(:puller) { ::Sidekiq::Debouncer::Poller.new(sidekiq_config) }
let(:schedule_set) { Sidekiq::Debouncer::Set.new }
let(:processor) do
sidekiq_version = Gem::Version.new(Sidekiq::VERSION)
if sidekiq_version >= Gem::Version.new("7.0")
::Sidekiq::Processor.new(sidekiq_config.default_capsule) { |*args| }
else
::Sidekiq::Processor.new(sidekiq_config) { |*args| }
end
end
let(:processor) { ::Sidekiq::Processor.new(sidekiq_config.default_capsule) { |*args| } }

before do
Timecop.freeze(time_start)
Expand Down
Loading