Module: HAProxy::ServerList

Included in:
Backend, Listener
Defined in:
lib/haproxy/config.rb

Overview

Contains shared methods for config objects that contain a list of servers. The including class is expected to have an instance variable called :servers that contains a hash of server configurations.

Instance Method Summary collapse

Instance Method Details

#add_server(name, host, options) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/haproxy/config.rb', line 14

def add_server(name, host, options)
  options ||= {}
  new_server = options[:template] ? options[:template].clone : Server.new
  new_server.name       = name
  new_server.host       = host
  new_server.port       = options[:port] if options[:port]
  new_server.attributes ||= options[:attributes] || {}
  servers[name] = new_server
  new_server
end