Skip to content

Commit

Permalink
fix compabitability with sidekiq < 7
Browse files Browse the repository at this point in the history
  • Loading branch information
mattyr committed Nov 5, 2023
1 parent 1d4589c commit 209ec27
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions lib/sidecloq/locker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ class Locker
def initialize(options = {})
# we keep a connection from the pool by default
@redis = options[:redis] || Sidekiq.redis_pool.checkout
# for compatibility with sidekiq < 7, we need to convert the Redis
# instance to a RedisClient instance, which redlock requires
if defined?(Redis) && @redis.instance_of?(Redis)
@redis = RedisClient.new(@redis.connection.except(:location))
end
@key = options[:lock_key] || DEFAULT_LOCK_KEY
@ttl = options[:ttl] || 60
@check_interval = options[:check_interval] || 15
Expand Down
2 changes: 1 addition & 1 deletion test/test_runner.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'helper'
require_relative 'helper'

class TestRunner < Sidecloq::Test
describe 'runner' do
Expand Down
2 changes: 1 addition & 1 deletion test/test_schedule.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'helper'
require_relative 'helper'

class TestSchedule < Sidecloq::Test
describe 'schedule' do
Expand Down

0 comments on commit 209ec27

Please sign in to comment.