mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Merge pull request #535 from Verba/schedule-bulk
Support scheduled jobs in bulk push
This commit is contained in:
commit
166edb8f68
2 changed files with 9 additions and 1 deletions
|
@ -92,7 +92,9 @@ module Sidekiq
|
|||
def self.raw_push(normed, payload) # :nodoc:
|
||||
pushed = false
|
||||
Sidekiq.redis do |conn|
|
||||
if normed['at']
|
||||
if normed['at'] && payload.is_a?(Array)
|
||||
pushed = conn.zadd('schedule', payload.map {|hash| [normed['at'].to_s, hash]})
|
||||
elsif normed['at']
|
||||
pushed = conn.zadd('schedule', normed['at'].to_s, payload)
|
||||
else
|
||||
_, pushed = conn.multi do
|
||||
|
|
|
@ -28,6 +28,12 @@ class TestScheduling < MiniTest::Unit::TestCase
|
|||
assert ScheduledWorker.perform_in(5.days.from_now, 'mike')
|
||||
@redis.verify
|
||||
end
|
||||
|
||||
it 'schedules multiple jobs at once' do
|
||||
@redis.expect :zadd, true, ['schedule', Array]
|
||||
assert Sidekiq::Client.push_bulk('class' => ScheduledWorker, 'args' => ['mike', 'mike'], 'at' => 600)
|
||||
@redis.verify
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue