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) ⇒ IdleEventDetector
constructor
A new instance of IdleEventDetector.
- #notify ⇒ Object
- #start(&block) ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(initial_interval, continuous_interval, check_interval = 5) ⇒ IdleEventDetector
Returns a new instance of IdleEventDetector.
4 5 6 7 8 9 |
# File 'lib/flydata/fluent-plugins/idle_event_detector.rb', line 4 def initialize(initial_interval, continuous_interval, check_interval = 5) @mutex = Mutex.new @initial_interval = initial_interval @continuous_interval = continuous_interval @check_interval = check_interval end |
Instance Method Details
#notify ⇒ Object
34 35 36 |
# File 'lib/flydata/fluent-plugins/idle_event_detector.rb', line 34 def notify update_last_event_time end |
#start(&block) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/flydata/fluent-plugins/idle_event_detector.rb', line 11 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
26 27 28 29 30 31 32 |
# File 'lib/flydata/fluent-plugins/idle_event_detector.rb', line 26 def stop @thread.exit if @thread @thread = nil @is_absent = false @last_event_at = @timestamp = nil @callback = nil end |