class MainLoop::Handler
Attributes
dispatcher[R]
logger[R]
name[R]
Public Class Methods
new(dispatcher, name, *_args, retry_count: 0, logger: nil, **_kwargs)
click to toggle source
# File lib/main_loop/handler.rb, line 8 def initialize(dispatcher, name, *_args, retry_count: 0, logger: nil, **_kwargs) @dispatcher = dispatcher @name = name @code = 0 @retry_count = retry_count @logger = logger || Logger.new(nil) @handler_type = 'Unknown' end
Public Instance Methods
finished?()
click to toggle source
:nocov:
# File lib/main_loop/handler.rb, line 58 def finished? @finished end
handle_retry()
click to toggle source
:nocov:
# File lib/main_loop/handler.rb, line 81 def handle_retry if @retry_count == :unlimited logger.info "#{@handler_type}[#{name}] retry...." self.run(&@block) elsif @retry_count && (@retry_count -= 1) >= 0 logger.info "#{@handler_type}[#{name}] retry...." self.run(&@block) else publish(:term) end end
id(*_args)
click to toggle source
:nocov:
# File lib/main_loop/handler.rb, line 18 def id(*_args) raise 'not implemented!' end
kill(*_args)
click to toggle source
:nocov:
# File lib/main_loop/handler.rb, line 36 def kill(*_args) raise 'not implemented!' end
on_term(&block)
click to toggle source
:nocov:
# File lib/main_loop/handler.rb, line 53 def on_term &block @on_term = block end
publish(event)
click to toggle source
:nocov:
# File lib/main_loop/handler.rb, line 48 def publish(event) dispatcher.bus.puts(event) end
reap(*_args)
click to toggle source
:nocov:
# File lib/main_loop/handler.rb, line 42 def reap(*_args) raise 'not implemented!' end
run(*_args)
click to toggle source
:nocov:
# File lib/main_loop/handler.rb, line 30 def run(*_args) raise 'not implemented!' end
running?()
click to toggle source
:nocov:
# File lib/main_loop/handler.rb, line 70 def running? !finished? end
success?()
click to toggle source
:nocov:
# File lib/main_loop/handler.rb, line 64 def success? finished? && @success end
term(*_args)
click to toggle source
:nocov:
# File lib/main_loop/handler.rb, line 24 def term(*_args) raise 'not implemented!' end
terminating?()
click to toggle source
:nocov:
# File lib/main_loop/handler.rb, line 76 def terminating? @terminating_at end