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:
parent
8269205a73
commit
2b58b74344
2 changed files with 11 additions and 8 deletions
|
|
@ -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)]
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue