Class: HAProxy::Parser
- Inherits:
-
Object
- Object
- HAProxy::Parser
- Defined in:
- lib/haproxy/parser.rb
Overview
Responsible for reading an HAProxy config file and building an HAProxy::Config instance.
Constant Summary collapse
- Error =
Raised when an error occurs during parsing.
Class.new(StandardError)
- SERVER_ATTRIBUTE_NAMES_1_3 =
haproxy 1.3
%w[ addr backup check cookie disabled fall id inter fastinter downinter maxconn maxqueue minconn port redir rise slowstart source track weight ]
- SERVER_ATTRIBUTE_NAMES_1_4 =
Added in haproxy 1.4
%w[error-limit observe on-error]
- SERVER_ATTRIBUTE_NAMES_1_5 =
Added in haproxy 1.5
%w[ agent-check agent-inter agent-port ca-file check-send-proxy check-ssl ciphers crl-file crt error-limit force-sslv3 force-tlsv10 force-tlsv11 force-tlsv12 no-sslv3 no-tls-tickets no-tlsv10 no-tlsv11 no-tlsv12 non-stick observe on-error on-marked-down on-marked-up send-proxy send-proxy-v2 send-proxy-v2-ssl send-proxy-v2-ssl-cn ssl verify verifyhost ]
- SERVER_ATTRIBUTE_NAMES_1_6 =
Added in haproxy 1.6
%w[ namespace no-ssl-reuse resolve-prefer resolvers sni tcp-ut ]
- SERVER_ATTRIBUTE_NAMES_1_7 =
Added in haproxy 1.7
%w[ agent-send init-addr resolve-net ]
- SERVER_ATTRIBUTE_NAMES_1_8 =
%w[ agent-addr check-sni enabled force-tlsv13 no-agent-check no-backup no-check no-check-ssl no-send-proxy no-send-proxy-v2 no-send-proxy-v2-ssl no-send-proxy-v2-ssl-cn no-ssl no-tlsv13 no-verifyhost ssl-max-ver ssl-min-ver ssl-reuse stick tls-tickets ]
- SERVER_ATTRIBUTE_NAMES_1_9 =
%w[ alpn check-alpn max-reuse npn pool-max-conn pool-purge-delay proto proxy-v2-options ].freeze
- SERVER_ATTRIBUTE_NAMES =
[ SERVER_ATTRIBUTE_NAMES_1_3, SERVER_ATTRIBUTE_NAMES_1_4, SERVER_ATTRIBUTE_NAMES_1_5, SERVER_ATTRIBUTE_NAMES_1_6, SERVER_ATTRIBUTE_NAMES_1_7, SERVER_ATTRIBUTE_NAMES_1_8, SERVER_ATTRIBUTE_NAMES_1_9, ].flatten.freeze
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
-
#parse_result ⇒ Object
Returns the value of attribute parse_result.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
-
#initialize(options = nil) ⇒ Parser
constructor
A new instance of Parser.
- #parse(config_text) ⇒ Object
- #parse_file(filename) ⇒ Object
Constructor Details
#initialize(options = nil) ⇒ Parser
Returns a new instance of Parser.
52 53 54 55 56 57 58 |
# File 'lib/haproxy/parser.rb', line 52 def initialize( = nil) ||= {} = {verbose: false}.merge() self. = self.verbose = [:verbose] end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
50 51 52 |
# File 'lib/haproxy/parser.rb', line 50 def end |
#parse_result ⇒ Object
Returns the value of attribute parse_result.
50 51 52 |
# File 'lib/haproxy/parser.rb', line 50 def parse_result @parse_result end |
#verbose ⇒ Object
Returns the value of attribute verbose.
50 51 52 |
# File 'lib/haproxy/parser.rb', line 50 def verbose @verbose end |
Instance Method Details
#parse(config_text) ⇒ Object
65 66 67 68 69 |
# File 'lib/haproxy/parser.rb', line 65 def parse(config_text) result = parse_config_text(config_text) self.parse_result = result build_config(result) end |
#parse_file(filename) ⇒ Object
60 61 62 63 |
# File 'lib/haproxy/parser.rb', line 60 def parse_file(filename) config_text = File.read(filename) parse(config_text) end |