Skip to content

Commit

Permalink
dont use kwargs to avoid stupid problems with rspec-mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
kukicola committed May 1, 2024
1 parent 2435c38 commit ba51177
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/sidekiq/debouncer/enq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def initialize(config)

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

final_args = job_args.map { |elem| Sidekiq.load_json(elem.split("-", 2)[1]) }
job_class = job.split("/")[1]
Expand Down
2 changes: 1 addition & 1 deletion lib/sidekiq/debouncer/lua_commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module LuaCommands

def define_lua_command(command, script)
sha = Digest::SHA1.hexdigest(script)
define_method(command) do |conn, keys: nil, argv: nil|
define_method(command) do |conn, keys, argv|
retryable = true
begin
conn.call("EVALSHA", sha, keys.size, *keys, *argv)
Expand Down
2 changes: 1 addition & 1 deletion lib/sidekiq/debouncer/middleware/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def debounce(klass, job)
args_stringified = "#{SecureRandom.hex(12)}-#{Sidekiq.dump_json(job["args"])}"

redis do |connection|
redis_debounce(connection, keys: [Sidekiq::Debouncer::Enq::SET, key], argv: [args_stringified, time, @debounce_key_ttl])
redis_debounce(connection, [Sidekiq::Debouncer::Enq::SET, key], [args_stringified, time, @debounce_key_ttl])
end

# prevent normal sidekiq flow
Expand Down
2 changes: 1 addition & 1 deletion spec/sidekiq/debouncer/lua/zpopbyscore_multi_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

it "pops element from sorted set and returns it with score" do
result = Sidekiq.redis do |connection|
fake_class.new.zpopbyscore_multi(connection, keys: ["sample_set"], argv: [11111112])
fake_class.new.zpopbyscore_multi(connection, ["sample_set"], [11111112])
end
expect(result).to eq(["key1", "key2"])

Expand Down
2 changes: 1 addition & 1 deletion spec/sidekiq/debouncer/lua/zpopbyscore_withscore_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

it "pops element from sorted set and returns it with score" do
result = Sidekiq.redis do |connection|
fake_class.new.zpopbyscore_withscore(connection, keys: ["sample_set"], argv: ["11111112"])
fake_class.new.zpopbyscore_withscore(connection, ["sample_set"], ["11111112"])
end
expect(result).to eq(["key1", "11111111"])

Expand Down

0 comments on commit ba51177

Please sign in to comment.