Class: Fluent::DockerInspectInput::TimerWatcher

Inherits:
Coolio::TimerWatcher
  • Object
show all
Defined in:
lib/fluent/plugin/in_docker_inspect.rb

Instance Method Summary collapse

Constructor Details

#initialize(interval, repeat, log, &callback) ⇒ TimerWatcher



27
28
29
30
31
32
33
34
# File 'lib/fluent/plugin/in_docker_inspect.rb', line 27

def initialize(interval, repeat, log, &callback)
  @callback = callback
  # Avoid long shutdown time
  @num_call = 0
  @call_interval = interval / 10
  @log = log
  super(10, repeat)
end

Instance Method Details

#on_timerObject



36
37
38
39
40
41
42
43
44
45
# File 'lib/fluent/plugin/in_docker_inspect.rb', line 36

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