Class: ProxyMgr::Haproxy::SocketManager
- Inherits:
-
Object
- Object
- ProxyMgr::Haproxy::SocketManager
- Includes:
- Logging
- Defined in:
- lib/proxymgr/haproxy/socket_manager.rb
Instance Attribute Summary collapse
-
#sockets ⇒ Object
readonly
Returns the value of attribute sockets.
Instance Method Summary collapse
-
#initialize ⇒ SocketManager
constructor
A new instance of SocketManager.
- #shutdown ⇒ Object
- #update(backends) ⇒ Object
Methods included from Logging
Constructor Details
#initialize ⇒ SocketManager
Returns a new instance of SocketManager.
11 12 13 |
# File 'lib/proxymgr/haproxy/socket_manager.rb', line 11 def initialize @sockets = {} end |
Instance Attribute Details
#sockets ⇒ Object (readonly)
Returns the value of attribute sockets.
9 10 11 |
# File 'lib/proxymgr/haproxy/socket_manager.rb', line 9 def sockets @sockets end |
Instance Method Details
#shutdown ⇒ Object
15 16 17 18 19 |
# File 'lib/proxymgr/haproxy/socket_manager.rb', line 15 def shutdown @sockets.each do |_port, socket| socket.close end end |
#update(backends) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/proxymgr/haproxy/socket_manager.rb', line 21 def update(backends) fds = backends.each_with_object({}) do |(name, backend), mapping| socket = for_port(backend.port) mapping[backend.port] = socket.fileno if socket end (@sockets.keys - fds.keys).each do |port| @sockets.delete(port).close end fds end |