Class: Fluent::Plugin::TDMonitorAgentInput::TimerWatcher
- Inherits:
-
Coolio::TimerWatcher
- Object
- Coolio::TimerWatcher
- Fluent::Plugin::TDMonitorAgentInput::TimerWatcher
- Defined in:
- lib/fluent/plugin/in_td_monitor_agent.rb
Instance Method Summary collapse
-
#initialize(interval, repeat, log, &callback) ⇒ TimerWatcher
constructor
A new instance of TimerWatcher.
- #on_timer ⇒ Object
Constructor Details
#initialize(interval, repeat, log, &callback) ⇒ TimerWatcher
Returns a new instance of TimerWatcher.
36 37 38 39 40 41 42 43 |
# File 'lib/fluent/plugin/in_td_monitor_agent.rb', line 36 def initialize(interval, repeat, log, &callback) @callback = callback # Avoid long shutdown time @num_call = 0 @call_interval = interval / 10 @log = log super(5, repeat) end |
Instance Method Details
#on_timer ⇒ Object
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/fluent/plugin/in_td_monitor_agent.rb', line 45 def on_timer @num_call += 1 if @num_call >= @call_interval @num_call = 0 @callback.call end rescue => e @log.error e.to_s @log.error_backtrace end |