Skip to content

Commit

Permalink
Dispatch when done
Browse files Browse the repository at this point in the history
  • Loading branch information
Pablo Cantero committed Dec 24, 2016
1 parent 5ebfed5 commit ac52dab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions lib/shoryuken/manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ def initialize(fetcher, polling_strategy)
@fetcher = fetcher
@polling_strategy = polling_strategy

# @heartbeat = Concurrent::TimerTask.new(run_now: true, execution_interval: 1, timeout_interval: 60) { dispatch }
@heartbeat = Concurrent::TimerTask.new(run_now: true, execution_interval: 1, timeout_interval: 60) { dispatch }

@pool = Concurrent::FixedThreadPool.new(@count, max_queue: @count)
end

def start
logger.info { 'Starting' }

# @heartbeat.execute
@heartbeat.execute
dispatch
end

Expand All @@ -40,7 +40,7 @@ def stop(options = {})

logger.info { "Shutting down workers" }

# @heartbeat.kill
@heartbeat.kill

if options[:shutdown]
hard_shutdown_in(options[:timeout])
Expand All @@ -51,6 +51,8 @@ def stop(options = {})

def processor_done(queue)
logger.debug { "Process done for '#{queue}'" }

dispatch
end

private
Expand All @@ -73,7 +75,6 @@ def dispatch

ensure
@dispatching.make_false
dispatch
end

def busy
Expand Down
2 changes: 1 addition & 1 deletion lib/shoryuken/processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def process(queue, sqs_msg)
worker.class.server_middleware.invoke(worker, queue, sqs_msg, body) do
worker.perform(sqs_msg, body)
end

ensure
@manager.processor_done(queue)
end

Expand Down

0 comments on commit ac52dab

Please sign in to comment.