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

Returns a new instance of TimerWatcher.



40
41
42
43
44
45
46
47
# File 'lib/fluent/plugin/in_docker_inspect.rb', line 40

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



49
50
51
52
53
54
55
56
57
58
# File 'lib/fluent/plugin/in_docker_inspect.rb', line 49

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