class Proxy::Dynflow::Runner::Dispatcher::RunnerActor
Public Class Methods
new(dispatcher, suspended_action, runner, clock, logger, _options = {})
click to toggle source
# File lib/smart_proxy_dynflow/runner/dispatcher.rb, line 16 def initialize(dispatcher, suspended_action, runner, clock, logger, _options = {}) @dispatcher = dispatcher @clock = clock @ticker = dispatcher.ticker @logger = logger @suspended_action = suspended_action @runner = runner @finishing = false end
Public Instance Methods
dispatch_updates(updates)
click to toggle source
# File lib/smart_proxy_dynflow/runner/dispatcher.rb, line 54 def dispatch_updates(updates) updates.each { |receiver, update| (receiver || @suspended_action) << update } # This is a workaround when the runner does not accept the suspended action main_key = updates.keys.any?(&:nil?) ? nil : @suspended_action main_process = updates[main_key] finish if main_process&.exit_status end
external_event(event)
click to toggle source
# File lib/smart_proxy_dynflow/runner/dispatcher.rb, line 90 def external_event(event) dispatch_updates(@runner.external_event(event)) end
finish()
click to toggle source
# File lib/smart_proxy_dynflow/runner/dispatcher.rb, line 77 def finish @logger.debug("finish runner #{@runner.id}") @finishing = true @dispatcher.finish(@runner.id) end
kill()
click to toggle source
# File lib/smart_proxy_dynflow/runner/dispatcher.rb, line 70 def kill @logger.debug("kill runner #{@runner.id}") @runner.kill rescue => e handle_exception(e, false) end
on_envelope(*args)
click to toggle source
Calls superclass method
# File lib/smart_proxy_dynflow/runner/dispatcher.rb, line 26 def on_envelope(*args) super rescue => e handle_exception(e) end
refresh_output()
click to toggle source
# File lib/smart_proxy_dynflow/runner/dispatcher.rb, line 49 def refresh_output @logger.debug("refresh output #{@runner.id}") dispatch_updates(@runner.run_refresh_output) end
refresh_runner()
click to toggle source
# File lib/smart_proxy_dynflow/runner/dispatcher.rb, line 41 def refresh_runner @logger.debug("refresh runner #{@runner.id}") dispatch_updates(@runner.run_refresh) ensure @refresh_planned = false plan_next_refresh end
start_runner()
click to toggle source
# File lib/smart_proxy_dynflow/runner/dispatcher.rb, line 32 def start_runner @logger.debug("start runner #{@runner.id}") set_timeout if @runner.timeout_interval @runner.start refresh_runner ensure plan_next_refresh end
start_termination(*args)
click to toggle source
Calls superclass method
# File lib/smart_proxy_dynflow/runner/dispatcher.rb, line 83 def start_termination(*args) @logger.debug("terminate #{@runner.id}") super @runner.close finish_termination end
timeout_runner()
click to toggle source
# File lib/smart_proxy_dynflow/runner/dispatcher.rb, line 63 def timeout_runner @logger.debug("timeout runner #{@runner.id}") @runner.timeout rescue => e handle_exception(e, false) end
Private Instance Methods
handle_exception(exception, fatal = true)
click to toggle source
# File lib/smart_proxy_dynflow/runner/dispatcher.rb, line 110 def handle_exception(exception, fatal = true) @dispatcher.handle_command_exception(@runner.id, exception, fatal) end
plan_next_refresh()
click to toggle source
# File lib/smart_proxy_dynflow/runner/dispatcher.rb, line 102 def plan_next_refresh if !@finishing && !@refresh_planned @logger.debug("planning to refresh #{@runner.id}") @ticker.tell([:add_event, reference, :refresh_runner]) @refresh_planned = true end end
set_timeout()
click to toggle source
# File lib/smart_proxy_dynflow/runner/dispatcher.rb, line 96 def set_timeout timeout_time = Time.now.getlocal + @runner.timeout_interval @logger.debug("setting timeout for #{@runner.id} to #{timeout_time}") @clock.ping(reference, timeout_time, :timeout_runner) end