Documentation ¶
Index ¶
Constants ¶
const ( // MetricLabelLoadbalance metric label name loadbalance MetricLabelLoadbalance = "loadbalance" // MetricLabelBackend metric label name for loadbalance backend MetricLabelBackend = "backend" // MetricLabelFrontent metric label name for loadbalance frontend MetricLabelFrontent = "frontend" // MetricLabelServer metric label name for loadbalance server MetricLabelServer = "server" // MetricLabelServerAddress metric label name for loadbalance server MetricLabelServerAddress = "address" // MetricLabelServiceName metric label name for service name MetricLabelServiceName = "serviceName" // MetricLabelNamespace metric label name for bcs namespace MetricLabelNamespace = "namespace" // EnvBcsLoadbalanceName env BCS_LOADBALANCE_NAME EnvBcsLoadbalanceName = "BCS_LOADBALANCE_NAME" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend struct { Host string // host name for endpoint IP string // overlap ip info Port int // listen port Weight int // backend weight }
Backend hold Backend info for load balance
type BackendList ¶
type BackendList []Backend
BackendList define Backend list implementing sorter interface
func (BackendList) Len ¶
func (bl BackendList) Len() int
Len is the number of elements in the collection.
func (BackendList) Less ¶
func (bl BackendList) Less(i, j int) bool
Less reports whether the element with index i should sort before the element with index j.
func (BackendList) Swap ¶
func (bl BackendList) Swap(i, j int)
Swap swaps the elements with indexes i and j.
type FourLayerServiceInfo ¶
type FourLayerServiceInfo struct { ServiceInfo Backends BackendList // tcp Backend }
FourLayerServiceInfo to hold tcp and udp service info
func NewFourLayerServiceInfo ¶
func NewFourLayerServiceInfo(s ServiceInfo, bl BackendList) FourLayerServiceInfo
NewFourLayerServiceInfo to new a FourLayerServiceInfo
func (*FourLayerServiceInfo) AddBackend ¶
func (tsi *FourLayerServiceInfo) AddBackend(b Backend)
AddBackend add backend to list
func (*FourLayerServiceInfo) SortBackends ¶
func (tsi *FourLayerServiceInfo) SortBackends()
SortBackends sort backend list
type FourLayerServiceInfoList ¶
type FourLayerServiceInfoList []FourLayerServiceInfo
FourLayerServiceInfoList define serviceInfo list implementing sorter interface
func (FourLayerServiceInfoList) Len ¶
func (til FourLayerServiceInfoList) Len() int
Len is the number of elements in the collection.
func (FourLayerServiceInfoList) Less ¶
func (til FourLayerServiceInfoList) Less(i, j int) bool
Less reports whether the element with index i should sort before the element with index j.
func (FourLayerServiceInfoList) Swap ¶
func (til FourLayerServiceInfoList) Swap(i, j int)
Swap swaps the elements with indexes i and j.
type HTTPBackend ¶
type HTTPBackend struct { Path string UpstreamName string BackendList }
HTTPBackend hold Backend info for load balance
type HTTPBackendList ¶
type HTTPBackendList []HTTPBackend
HTTPBackendList to ho
func (HTTPBackendList) Less ¶
func (hbl HTTPBackendList) Less(i, j int) bool
Less reports whether the element with index i should sort before the element with index j.
func (HTTPBackendList) Swap ¶
func (hbl HTTPBackendList) Swap(i, j int)
Swap swaps the elements with indexes i and j.
type HTTPServiceInfo ¶
type HTTPServiceInfo struct { ServiceInfo Backends HTTPBackendList BCSVHost string // virtual host name, only use for http/hhtps ACL string // ACL match rules, reserved // If SessionAffinity is set and without CookieStickySession, requests are routed to // a backend based on client ip. If both SessionAffinity and CookieStickSession are // set, a SERVERID cookie is inserted by the loadbalancer and used to route subsequent // requests. If neither is set, requests are routed based on the algorithm. // CookieStickySession use a cookie to enable sticky sessions. // The name of the cookie is SERVERID // This only can be used in http services CookieSession bool // Path string //location nginx to transport specified uri SSLFlag bool }
HTTPServiceInfo http service info
func NewHTTPServiceInfo ¶
func NewHTTPServiceInfo(s ServiceInfo, host string) HTTPServiceInfo
NewHTTPServiceInfo construct http service info
func (*HTTPServiceInfo) AddBackend ¶
func (hsi *HTTPServiceInfo) AddBackend(b HTTPBackend)
AddBackend add backend to list
func (*HTTPServiceInfo) SortBackends ¶
func (hsi *HTTPServiceInfo) SortBackends()
SortBackends sort backend list
type HTTPServiceInfoList ¶
type HTTPServiceInfoList []HTTPServiceInfo
HTTPServiceInfoList to hold http service info list
func (*HTTPServiceInfoList) AddItem ¶
func (hil *HTTPServiceInfoList) AddItem(h HTTPServiceInfo)
AddItem for add HTTPServiceInfoItem to HTTPServiceInfoList
func (HTTPServiceInfoList) Len ¶
func (hil HTTPServiceInfoList) Len() int
Len is the number of elements in the collection.
func (HTTPServiceInfoList) Less ¶
func (hil HTTPServiceInfoList) Less(i, j int) bool
Less reports whether the element with index i should sort before the element with index j.
func (*HTTPServiceInfoList) SortBackends ¶
func (hil *HTTPServiceInfoList) SortBackends()
SortBackends sort https backends by path, no need to sort HTTPBackend.BackendList because sort before assgin
func (HTTPServiceInfoList) Swap ¶
func (hil HTTPServiceInfoList) Swap(i, j int)
Swap swaps the elements with indexes i and j.
type HealthInfo ¶
HealthInfo to storage bcs-loadbalance health info
type ServiceInfo ¶
type ServiceInfo struct { Name string // serviceName ServicePort int // export port Balance string // loadbalance algorithm, default source MaxConn int // max connection for service SessionAffinity bool }
ServiceInfo hold http/https info
type TemplateData ¶
type TemplateData struct { HTTP HTTPServiceInfoList // HTTP service info HTTPS HTTPServiceInfoList // HTTPS service info TCP FourLayerServiceInfoList // TCP service info UDP FourLayerServiceInfoList // UDP service info LogFlag bool // log flag, true will open log writer SSLCert string // SSL certificate path, true will listen https }
TemplateData data holder for haproxy.cfg.template