Skip to content

Commit

Permalink
updated Sidekiq::Client.push_bulk to support ActiveSupport::Duration …
Browse files Browse the repository at this point in the history
…in the at argument (#4996)
  • Loading branch information
cameronmccord2 committed Sep 21, 2021
1 parent a3b4faf commit e9d16db
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/sidekiq/client.rb
Expand Up @@ -95,7 +95,7 @@ def push_bulk(items)
return [] if args.empty? # no jobs to push

at = items.delete("at")
raise ArgumentError, "Job 'at' must be a Numeric or an Array of Numeric timestamps" if at && (Array(at).empty? || !Array(at).all?(Numeric))
raise ArgumentError, "Job 'at' must be a Numeric or an Array of Numeric timestamps" if at && (Array(at).empty? || !Array(at).all?{|entry| entry.is_a?(Numeric) })
raise ArgumentError, "Job 'at' Array must have same size as 'args' Array" if at.is_a?(Array) && at.size != args.size

normed = normalize_item(items)
Expand Down
5 changes: 5 additions & 0 deletions test/test_client.rb
Expand Up @@ -148,6 +148,11 @@ class QueuedWorker
assert_equal second_at, Sidekiq::ScheduledSet.new.find_job(second_jid).at
end

it 'can push jobs scheduled using ActiveSupport::Duration' do
jids = Sidekiq::Client.push_bulk('class' => QueuedWorker, 'args' => [[1], [2]], 'at' => [1.seconds, 111.seconds])
assert_equal 2, jids.size
end

it 'returns the jids for the jobs' do
Sidekiq::Client.push_bulk('class' => 'QueuedWorker', 'args' => (1..2).to_a.map { |x| Array(x) }).each do |jid|
assert_match(/[0-9a-f]{12}/, jid)
Expand Down

0 comments on commit e9d16db

Please sign in to comment.