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, &callback) ⇒ TimerWatcher
constructor
A new instance of TimerWatcher.
- #on_timer ⇒ Object
Constructor Details
#initialize(title, interval, repeat, log, checker, &callback) ⇒ TimerWatcher
Returns a new instance of TimerWatcher.
66 67 68 69 70 71 72 73 |
# File 'lib/fluent/plugin_helper/timer.rb', line 66 def initialize(title, interval, repeat, log, checker, &callback) @title = title @callback = callback @repeat = repeat @log = log @checker = checker super(interval, repeat) end |
Instance Method Details
#on_timer ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/fluent/plugin_helper/timer.rb', line 75 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 if attached? detach unless @repeat end end |