mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Merge pull request #534 from Verba/inline-push-bulk
Run .push_bulk calls inline in inline testing mode
This commit is contained in:
commit
babdab431e
3 changed files with 14 additions and 9 deletions
|
@ -65,13 +65,7 @@ module Sidekiq
|
||||||
end.compact
|
end.compact
|
||||||
|
|
||||||
pushed = false
|
pushed = false
|
||||||
Sidekiq.redis do |conn|
|
pushed = raw_push(normed, payloads)
|
||||||
_, pushed = conn.multi do
|
|
||||||
conn.sadd('queues', normed['queue'])
|
|
||||||
conn.rpush("queue:#{normed['queue']}", payloads)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
pushed ? payloads.size : nil
|
pushed ? payloads.size : nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,11 @@ module Sidekiq
|
||||||
#
|
#
|
||||||
singleton_class.class_eval do
|
singleton_class.class_eval do
|
||||||
alias_method :raw_push_old, :raw_push
|
alias_method :raw_push_old, :raw_push
|
||||||
def raw_push(hash, _)
|
def raw_push(normed, payload)
|
||||||
hash['class'].constantize.new.perform(*Sidekiq.load_json(Sidekiq.dump_json(hash['args'])))
|
Array.wrap(payload).each do |hash|
|
||||||
|
normed['class'].constantize.new.perform(*Sidekiq.load_json(hash)['args'])
|
||||||
|
end
|
||||||
|
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -80,6 +80,14 @@ class TestInline < MiniTest::Unit::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'stubs the push_bulk call when in testing mode' do
|
||||||
|
assert Sidekiq::Client.push_bulk({'class' => InlineWorker, 'args' => [true, true]})
|
||||||
|
|
||||||
|
assert_raises InlineError do
|
||||||
|
Sidekiq::Client.push_bulk({'class' => InlineWorker, 'args' => [true, false]})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it 'should relay parameters through json' do
|
it 'should relay parameters through json' do
|
||||||
assert Sidekiq::Client.enqueue(InlineWorkerWithTimeParam, Time.now)
|
assert Sidekiq::Client.enqueue(InlineWorkerWithTimeParam, Time.now)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue