Class: Fluent::ExHttpInput::KeepaliveManager

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

Defined Under Namespace

Classes: TimerValue

Instance Method Summary collapse

Constructor Details

#initialize(timeout) ⇒ KeepaliveManager



19
20
21
22
23
# File 'lib/fluent/plugin/in_http_ex.rb', line 19

def initialize(timeout)
  super(1, true)
  @cons = {}
  @timeout = timeout.to_i
end

Instance Method Details

#add(sock) ⇒ Object



25
26
27
# File 'lib/fluent/plugin/in_http_ex.rb', line 25

def add(sock)
  @cons[sock] = sock
end

#delete(sock) ⇒ Object



29
30
31
# File 'lib/fluent/plugin/in_http_ex.rb', line 29

def delete(sock)
  @cons.delete(sock)
end

#on_timerObject



33
34
35
36
37
38
39
# File 'lib/fluent/plugin/in_http_ex.rb', line 33

def on_timer
  @cons.each_pair {|sock,val|
    if sock.step_idle > @timeout
      sock.close unless @timeout == 0
    end
  }
end