1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

redis-client: Fix ZADD compatibility (#5387)

This commit is contained in:
Jean byroot Boussier 2022-06-13 15:27:57 +02:00 committed by GitHub
parent 8269205a73
commit 2b58b74344
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 8 deletions

View file

@ -220,7 +220,7 @@ module Sidekiq
def atomic_push(conn, payloads)
if payloads.first.key?("at")
conn.zadd("schedule", *payloads.map { |hash|
conn.zadd("schedule", payloads.flat_map { |hash|
at = hash.delete("at").to_s
[at, Sidekiq.dump_json(hash)]
})

View file

@ -271,13 +271,16 @@ describe Sidekiq::Client do
assert_equal 1_000, jids.size
end
it "can push jobs scheduled at different times" do
first_at = Time.new(2019, 1, 1)
second_at = Time.new(2019, 1, 2)
jids = Sidekiq::Client.push_bulk("class" => QueuedWorker, "args" => [[1], [2]], "at" => [first_at.to_f, second_at.to_f])
(first_jid, second_jid) = jids
assert_equal first_at, Sidekiq::ScheduledSet.new.find_job(first_jid).at
assert_equal second_at, Sidekiq::ScheduledSet.new.find_job(second_jid).at
[1, 2, 3].each do |job_count|
it "can push #{job_count} jobs scheduled at different times" do
times = job_count.times.map { |i| Time.new(2019, 1, i + 1) }
args = job_count.times.map { |i| [i] }
jids = Sidekiq::Client.push_bulk("class" => QueuedWorker, "args" => args, "at" => times.map(&:to_f))
assert_equal job_count, jids.size
assert_equal times, jids.map { |jid| Sidekiq::ScheduledSet.new.find_job(jid).at }
end
end
it "can push jobs scheduled using ActiveSupport::Duration" do