Class: Fluent::IdleEventDetector
- Inherits:
-
Object
- Object
- Fluent::IdleEventDetector
- Defined in:
- lib/flydata/fluent-plugins/idle_event_detector.rb
Instance Method Summary collapse
-
#initialize(initial_interval, continuous_interval, check_interval = 5, idle_timeout = 3600) ⇒ IdleEventDetector
constructor
A new instance of IdleEventDetector.
- #notify ⇒ Object
- #start(&block) ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(initial_interval, continuous_interval, check_interval = 5, idle_timeout = 3600) ⇒ IdleEventDetector
Returns a new instance of IdleEventDetector.
4 5 6 7 8 9 10 |
# File 'lib/flydata/fluent-plugins/idle_event_detector.rb', line 4 def initialize(initial_interval, continuous_interval, check_interval = 5, idle_timeout = 3600) @mutex = Mutex.new @initial_interval = initial_interval @continuous_interval = continuous_interval @check_interval = check_interval @idle_timeout = idle_timeout end |
Instance Method Details
#notify ⇒ Object
35 36 37 |
# File 'lib/flydata/fluent-plugins/idle_event_detector.rb', line 35 def notify update_last_event_time end |
#start(&block) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/flydata/fluent-plugins/idle_event_detector.rb', line 12 def start(&block) raise "block must be given" unless block_given? @callback = block stop if @thread @last_event_at = @timestamp = Time.current @is_absent = false @thread = Thread.new do loop do check_state sleep @check_interval end end end |
#stop ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/flydata/fluent-plugins/idle_event_detector.rb', line 27 def stop @thread.exit if @thread @thread = nil @is_absent = false @last_event_at = @timestamp = nil @callback = nil end |