Skip to content

Commit

Permalink
Merge pull request #362 from Erol/introduce-dispatch-callback
Browse files Browse the repository at this point in the history
Introduce dispatch event
  • Loading branch information
phstc authored Apr 28, 2017
2 parents 2ffe7a5 + 3ef721d commit e331de9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/shoryuken.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ module Shoryuken
timeout: 8,
lifecycle_events: {
startup: [],
dispatch: [],
quiet: [],
shutdown: []
},
Expand Down
2 changes: 2 additions & 0 deletions lib/shoryuken/manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ def dispatch_now
return
end

fire_event(:dispatch)

logger.debug { "Ready: #{ready}, Busy: #{busy}, Active Queues: #{@polling_strategy.active_queues}" }

batched_queue?(queue) ? dispatch_batch(queue) : dispatch_single_messages(queue)
Expand Down
7 changes: 7 additions & 0 deletions spec/shoryuken/manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@
end
end

describe '#dispatch_now' do
it 'fires a dispatch event' do
expect(subject).to receive(:fire_event).with(:dispatch).once
subject.send(:dispatch_now)
end
end

describe '#dispatch_batch' do
it 'assings batch as a single message' do
q = polling_strategy.next_queue
Expand Down

0 comments on commit e331de9

Please sign in to comment.