Documentation ¶
Overview ¶
Package for parsing a HAproxy config file into a structured form. You might also use it to convert the file into a general JSON format.
Limitation: There is currently no way of writing the structure in HAproxy config file format.
Index ¶
- func ParseSockAddr(path string) (string, string)
- func RegisterEvent(group string, name string, emitter EmitEvent)
- func SeparateConfigLine(line string) ([]string, bool)
- func SeparateHostAndPort(address string) (string, int, error)
- func Uncomment(line string) (string, bool)
- type Acl
- type Backend
- type BackendParser
- type Bind
- type EmitEvent
- type EventType
- type Frontend
- type FrontendParser
- type Global
- type GlobalParser
- type NilParser
- type Parser
- type Server
- type Services
- type Socket
- type UseBackend
- type UseBackendClauses
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseSockAddr ¶
func RegisterEvent ¶
Registers an event listener to the event store.
The group is any of "global", "backend", "frontend" or "*" where the asterisk means any.
The name is the name is the first item on the line (i.e "bind", "acl", "use_backend" etc)
Example ¶
RegisterEvent("backend", "*", func(eventType EventType, line string, parser Parser) { if eventType == START_SECTION { fmt.Printf("EventType=%s, line=%s\n", eventType, line) } }) _, err := ParseFromFile("testdata/haproxy.cfg") if err != nil { fmt.Printf("Failed to parse data: %s", err) }
Output: EventType=start_section, line=backend profileEditingService_20000 EventType=start_section, line=backend accountCreationService_10000
func SeparateConfigLine ¶
Types ¶
type Acl ¶
type Backend ¶
type BackendParser ¶
type BackendParser struct {
Backend Backend
}
func NewBackendParser ¶
func NewBackendParser(name string) *BackendParser
func (*BackendParser) Install ¶
func (self *BackendParser) Install(s *Services)
func (*BackendParser) Name ¶
func (self *BackendParser) Name() string
type Frontend ¶
type FrontendParser ¶
type FrontendParser struct {
Frontend Frontend
}
func NewFrontendParser ¶
func NewFrontendParser(name string) *FrontendParser
func (*FrontendParser) Install ¶
func (self *FrontendParser) Install(s *Services)
func (*FrontendParser) Name ¶
func (self *FrontendParser) Name() string
type Global ¶
type GlobalParser ¶
type GlobalParser struct {
Global Global
}
The following keywords are supported in the "global" section :
Process management and security
chroot
daemon
gid
group
log
log-send-hostname
nbproc
pidfile
uid
ulimit-n
user
stats
node
description
Performance tuning
maxconn
maxpipes
noepoll
nokqueue
nopoll
nosepoll
nosplice
spread-checks
tune.bufsize
tune.chksize
tune.maxaccept
tune.maxpollevents
tune.maxrewrite
tune.rcvbuf.client
tune.rcvbuf.server
tune.sndbuf.client
tune.sndbuf.server
Debugging
debug
quiet
func NewGlobalParser ¶
func NewGlobalParser() *GlobalParser
func (*GlobalParser) Install ¶
func (self *GlobalParser) Install(s *Services)
func (*GlobalParser) Name ¶
func (self *GlobalParser) Name() string
type Server ¶
type Services ¶
type Services struct { Global Global `json:"global"` Frontends []Frontend `json:"frontends"` Backends []Backend `json:"backends"` }
func NewServices ¶
func NewServices() *Services
func ParseFromFile ¶
func ParseFromStdin ¶
type UseBackend ¶
type UseBackend struct { Name string `json:"name"` Condition *UseBackendClauses `json:"clauses"` Backend *Backend `json:"backend"` Acls []*Acl `json:"acls"` }
func (UseBackend) Hash ¶
func (u UseBackend) Hash() (uint64, error)
type UseBackendClauses ¶
type UseBackendClauses struct { ReverseJudge bool `json:"reserve_judge"` Any [][]string `json:"any"` }
func CreateUseBackendClauses ¶
func CreateUseBackendClauses(judge string, source []string) (*UseBackendClauses, error)
func (UseBackendClauses) Hash ¶
func (u UseBackendClauses) Hash() (uint64, error)