Documentation ¶
Index ¶
- Variables
- func NewManager(lbName, binPath, cfgPath, generatePath, backupPath, templatePath string, ...) (conf.Manager, error)
- type Config
- type EnvConfig
- type HTTPBackend
- type HTTPBackendList
- type HTTPFrontend
- type HTTPFrontendList
- type IPRealServerList
- type Manager
- func (m *Manager) CheckDifference(oldFile, curFile string) bool
- func (m *Manager) Collect(ch chan<- prometheus.Metric)
- func (m *Manager) Create(tmpData *types.TemplateData) (string, error)
- func (m *Manager) Describe(ch chan<- *prometheus.Desc)
- func (m *Manager) GetStatusFunction() restful.RouteFunction
- func (m *Manager) Reload(cfgFile string) error
- func (m *Manager) Replace(oldFile, curFile string) error
- func (m *Manager) Start() error
- func (m *Manager) Stop()
- func (m *Manager) TryUpdateWithoutReload(tmpData *types.TemplateData) (needReload bool)
- func (m *Manager) Validate(newFile string) bool
- type ProxyDefault
- type RealServer
- type RealServerList
- type RuntimeClient
- func (rc *RuntimeClient) ExecuteCommand(cmd string) error
- func (rc *RuntimeClient) ExecuteRaw(cmd string) (string, error)
- func (rc *RuntimeClient) GetInfo() (models.ProcessInfoHaproxy, error)
- func (rc *RuntimeClient) GetStats() *models.NativeStatsCollection
- func (rc *RuntimeClient) NewDisableServerCommand(backend, server string) string
- func (rc *RuntimeClient) NewEnableServerCommand(backend, server string) string
- func (rc *RuntimeClient) NewSetServerAddrCommand(backend, server, addr string, port int) string
- func (rc *RuntimeClient) NewSetServerWeightCommand(backend, server string, weight int) string
- type Server
- type Service
- type StatsFrontend
- type Status
- type StatusResponse
- type TCPListener
- type TCPListenerList
Constants ¶
This section is empty.
Variables ¶
var ( // LoadbalanceHaproxyStatsFetchStateMetric loadbalance metric for zookeeper connection LoadbalanceHaproxyStatsFetchStateMetric = prometheus.NewGauge( prometheus.GaugeOpts{ Namespace: "loadbalance", Subsystem: "haproxy", Name: "fetchstats_state", Help: "the state for haproxy stats fetching state, 0 for abnormal, 1 for normal", }, ) )
Functions ¶
Types ¶
type Config ¶
type Config struct { LogEnabled bool LogLevel string SockPath string ThreadNum int64 MaxConn int64 PidPath string SSLCert string DefaultProxyConfig *ProxyDefault Stats *StatsFrontend // map[ServicePort] HTTPMap map[int]*HTTPFrontend HTTPSMap map[int]*HTTPFrontend TCPMap map[int]*TCPListener // data for render template in order HTTPList HTTPFrontendList HTTPSList HTTPFrontendList TCPList TCPListenerList }
Config data structure for haproxy config file
type EnvConfig ¶
type EnvConfig struct { LogEnabled bool LogLevel string SockPath string ThreadNum int64 MaxConn int64 PidPath string SSLCert string Retries int64 Backlog int64 ProxyMaxConn int64 ProxyTimeoutConnection int64 ProxyTimeoutClient int64 ProxyTimeoutServer int64 ProxyTimeoutTunnel int64 ProxyTimeoutHTTPKeepAlive int64 ProxyTimeoutHTTPRequest int64 ProxyTimeoutQueue int64 ProxyTimeoutTarpit int64 ProxyOptions []string HTTPProxyOptions []string ServerHealthCheckInterval int64 ServerRiseHealthCheckNum int64 ServerFallHealthCheckNum int64 StatsFrontendPort int64 StatsFrontendURI string StatsFrontendAuthUser string StatsFrontendAuthPassword string }
EnvConfig config for haproxy from env
type HTTPBackend ¶
type HTTPBackend struct { Name string Domain string URL string Balance string HealthCheckInterval int64 RiseHealthCheckNum int64 FallHealthCheckNum int64 // map[IP] Servers map[string]*RealServer // data for render template in order ServerList RealServerList }
HTTPBackend http backend
type HTTPBackendList ¶
type HTTPBackendList []*HTTPBackend
HTTPBackendList http backend list
func (HTTPBackendList) Len ¶
func (hl HTTPBackendList) Len() int
func (HTTPBackendList) Less ¶
func (hl HTTPBackendList) Less(i, j int) bool
func (HTTPBackendList) Swap ¶
func (hl HTTPBackendList) Swap(i, j int)
type HTTPFrontend ¶
type HTTPFrontend struct { ServicePort int Name string // map[ServiceName] Backends map[string]*HTTPBackend // data for render template in order BackendList HTTPBackendList }
HTTPFrontend http frontend
type HTTPFrontendList ¶
type HTTPFrontendList []*HTTPFrontend
HTTPFrontendList http frontend list, sorted by service port
func (HTTPFrontendList) Len ¶
func (hl HTTPFrontendList) Len() int
func (HTTPFrontendList) Less ¶
func (hl HTTPFrontendList) Less(i, j int) bool
func (HTTPFrontendList) Swap ¶
func (hl HTTPFrontendList) Swap(i, j int)
type IPRealServerList ¶
type IPRealServerList []*RealServer
IPRealServerList real server list, sorted by ip
func (IPRealServerList) Len ¶
func (hl IPRealServerList) Len() int
func (IPRealServerList) Less ¶
func (hl IPRealServerList) Less(i, j int) bool
func (IPRealServerList) Swap ¶
func (hl IPRealServerList) Swap(i, j int)
type Manager ¶
type Manager struct { Cluster string // cluster id LoadbalanceName string // loadbalance instance id ConfigCache *Config // contains filtered or unexported fields }
Manager implements TemplateManager interface, control haproxy config file generating, validation, backup and reloading
func (*Manager) CheckDifference ¶
CheckDifference two file are difference, true is difference
func (*Manager) Collect ¶
func (m *Manager) Collect(ch chan<- prometheus.Metric)
Collect implements prometheus exporter Collect interface
func (*Manager) Create ¶
func (m *Manager) Create(tmpData *types.TemplateData) (string, error)
Create config file with tmpData,
func (*Manager) Describe ¶
func (m *Manager) Describe(ch chan<- *prometheus.Desc)
Describe implements prometheus exporter Describe interface
func (*Manager) GetStatusFunction ¶
func (m *Manager) GetStatusFunction() restful.RouteFunction
GetStatusFunction get status function
func (*Manager) TryUpdateWithoutReload ¶
func (m *Manager) TryUpdateWithoutReload(tmpData *types.TemplateData) (needReload bool)
TryUpdateWithoutReload update haproxy config without reloading needReload: true for reload
type ProxyDefault ¶
type ProxyDefault struct { Retries int64 Backlog int64 MaxConn int64 TimeoutConnection int64 TimeoutClient int64 TimeoutServer int64 TimeoutTunnel int64 TimeoutHTTPKeepAlive int64 TimeoutHTTPRequest int64 TimeoutQueue int64 TimeoutTarpit int64 Options []string HTTPOptions []string }
ProxyDefault default config for proxy
type RealServer ¶
RealServer backend config
func (*RealServer) Key ¶
func (rs *RealServer) Key() string
Key generate the map key for real server in backend
type RealServerList ¶
type RealServerList []*RealServer
RealServerList real server list, sorted by name
func (RealServerList) Len ¶
func (hl RealServerList) Len() int
func (RealServerList) Less ¶
func (hl RealServerList) Less(i, j int) bool
func (RealServerList) Swap ¶
func (hl RealServerList) Swap(i, j int)
type RuntimeClient ¶
type RuntimeClient struct { SockPath string Lock sync.Mutex // contains filtered or unexported fields }
RuntimeClient haproxy runtime client
func NewRuntimeClient ¶
func NewRuntimeClient(sockPath string) (*RuntimeClient, error)
NewRuntimeClient create runtime client
func (*RuntimeClient) ExecuteCommand ¶
func (rc *RuntimeClient) ExecuteCommand(cmd string) error
ExecuteCommand send command to haproxy
func (*RuntimeClient) ExecuteRaw ¶
func (rc *RuntimeClient) ExecuteRaw(cmd string) (string, error)
ExecuteRaw execute raw command
func (*RuntimeClient) GetInfo ¶
func (rc *RuntimeClient) GetInfo() (models.ProcessInfoHaproxy, error)
GetInfo get info of haproxy
func (*RuntimeClient) GetStats ¶
func (rc *RuntimeClient) GetStats() *models.NativeStatsCollection
GetStats get statistic of haproxy
func (*RuntimeClient) NewDisableServerCommand ¶
func (rc *RuntimeClient) NewDisableServerCommand(backend, server string) string
NewDisableServerCommand create new command that disable unused server
func (*RuntimeClient) NewEnableServerCommand ¶
func (rc *RuntimeClient) NewEnableServerCommand(backend, server string) string
NewEnableServerCommand create new command that enable unused server
func (*RuntimeClient) NewSetServerAddrCommand ¶
func (rc *RuntimeClient) NewSetServerAddrCommand(backend, server, addr string, port int) string
NewSetServerAddrCommand create new command that set server addr
func (*RuntimeClient) NewSetServerWeightCommand ¶
func (rc *RuntimeClient) NewSetServerWeightCommand(backend, server string, weight int) string
NewSetServerWeightCommand create new command that set server weight
type Server ¶
type Server struct { Name string `json:"name"` ServerName string `json:"server_name"` CurrentQueue int64 `json:"current_queue"` MaxQueue int64 `json:"max_queue"` CurrentSession int64 `json:"current_session"` MaxSession int64 `json:"max_session"` SessionLimit int64 `json:"session_limit"` SessionTotal int64 `json:"session_total"` BytesIn int64 `json:"bytes_in"` BytesOut int64 `json:"bytes_out"` RequestDeny int64 `json:"request_deny"` ResponseDeny int64 `json:"response_deny"` RequestError int64 `json:"request_error"` ConnectError int64 `json:"connect_error"` ResponseError int64 `json:"response_error"` ConnectRetry int64 `json:"connect_retry"` ConnectRedispatch int64 `json:"connect_redispatch"` Status string `json:"status"` Weight int64 `json:"weight"` Active int64 `json:"active_server_num"` Backup int64 `json:"backup_server_num"` CheckFail int64 `json:"check_fail_num"` CheckDown int64 `json:"check_down_num"` DownTime int64 `json:"down_time_second"` DownTimeTotal int64 `json:"down_time_total"` QueueMaxLimit int64 `json:"queue_limit"` CurrentSessionRate int64 `json:"current_session_rate"` MaxSessionRate int64 `json:"max_session_rate"` SessionRateLimit int64 `json:"session_rate_limit"` CheckStatus string `json:"check_status"` RequestRate int64 `json:"request_rate"` RequestMaxRate int64 `json:"request_max_rate"` RequestTotal int64 `json:"request_total"` LastSessionSecond int64 `json:"last_session_second"` LastCheckContent string `json:"last_check_content"` Address string `json:"address"` Mode string `json:"mode"` ConnectRate int64 `json:"connect_rate"` ConnectMaxRate int64 `json:"connect_max_rate"` }
Server server info for haproxy
type Service ¶
type Service struct { Frontend *Server `json:"frontend"` Backend *Server `json:"backend"` Servers []*Server `json:"servers"` }
Service service info for haproxy
type StatsFrontend ¶
StatsFrontend stats for frontend
type Status ¶
type Status struct { HaproxyPid int64 `json:"haproxy_pid"` UpTime string `json:"up_time"` UpTimeSecond int64 `json:"up_time_second"` ULimitN int64 `json:"ulimit_n"` SystemLimit string `json:"system_limits"` MaxSock int64 `json:"max_sock"` MaxConn int64 `json:"max_conn"` MaxPipes int64 `json:"max_pipes"` CurrentConn int64 `json:"current_conn"` CurrentPipes int64 `json:"current_pipes"` ConnRate int64 `json:"conn_rate"` ConnMaxRate int64 `json:"conn_max_rate"` Services []*Service `json:"services"` }
Status status info for haproxy
type StatusResponse ¶
type StatusResponse struct { Code int `json:"code"` Message string `json:"message"` Data *Status `json:"data"` }
StatusResponse response for status api
type TCPListener ¶
type TCPListener struct { ServicePort int Name string Balance string HealthCheckInterval int64 RiseHealthCheckNum int64 FallHealthCheckNum int64 // map[IP] Servers map[string]*RealServer // data for render template in order ServerList RealServerList }
TCPListener tcp frontend
type TCPListenerList ¶
type TCPListenerList []*TCPListener
TCPListenerList tcp listener list for sort
func (TCPListenerList) Len ¶
func (hl TCPListenerList) Len() int
func (TCPListenerList) Less ¶
func (hl TCPListenerList) Less(i, j int) bool
func (TCPListenerList) Swap ¶
func (hl TCPListenerList) Swap(i, j int)