Class: Fluent::PluginHelper::Timer::TimerWatcher
- Inherits:
-
Coolio::TimerWatcher
- Object
- Coolio::TimerWatcher
- Fluent::PluginHelper::Timer::TimerWatcher
- Defined in:
- lib/fluent/plugin_helper/timer.rb
Instance Method Summary collapse
-
#initialize(title, interval, repeat, log, checker, detacher, &callback) ⇒ TimerWatcher
constructor
A new instance of TimerWatcher.
- #on_timer ⇒ Object
Constructor Details
#initialize(title, interval, repeat, log, checker, detacher, &callback) ⇒ TimerWatcher
Returns a new instance of TimerWatcher.
69 70 71 72 73 74 75 76 77 |
# File 'lib/fluent/plugin_helper/timer.rb', line 69 def initialize(title, interval, repeat, log, checker, detacher, &callback) @title = title @callback = callback @repeat = repeat @log = log @checker = checker @detacher = detacher super(interval, repeat) end |
Instance Method Details
#on_timer ⇒ Object
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/fluent/plugin_helper/timer.rb', line 79 def on_timer @callback.call if @checker.call rescue => e @log.error "Unexpected error raised. Stopping the timer.", title: @title, error: e @log.error_backtrace detach @log.error "Timer detached.", title: @title ensure @detacher.call(self) unless @repeat end |