Class: HAProxyManager::HAPSocket

Inherits:
Object
  • Object
show all
Defined in:
lib/haproxy_manager/instance.rb

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ HAPSocket

Returns a new instance of HAPSocket.



85
86
87
# File 'lib/haproxy_manager/instance.rb', line 85

def initialize(file)
  @file = file
end

Instance Method Details

#execute(cmd) {|response| ... } ⇒ Object

Yields:

  • (response)


89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/haproxy_manager/instance.rb', line 89

def execute(cmd, &block)
  socket = UNIXSocket.new(@file)
  socket.write("#{cmd};")
  response = []
  socket.each do |line|
    data = line.strip
    next if data.empty?
    response << data
  end
  yield response if block_given?
  response
end