Documentation ¶
Index ¶
- Constants
- func BackendBasicCheck(conf *BackendBasic) error
- func BackendCheckCheck(conf *BackendCheck) error
- func BfeClusterConfCheck(conf *BfeClusterConf) error
- func ClusterBasicConfCheck(conf *ClusterBasicConf) error
- func ClusterConfCheck(conf *ClusterConf) error
- func ClusterToConfCheck(conf ClusterToConf) error
- func GetCookieKey(header string) (string, bool)
- func GslbBasicConfCheck(conf *GslbBasicConf) error
- func HashConfCheck(conf *HashConf) error
- func MatchStatusCode(statusCodeGet int, statusCodeExpect int) (bool, error)
- type BackendBasic
- type BackendCheck
- type BfeClusterConf
- type ClusterBasicConf
- type ClusterConf
- type ClusterToConf
- type FCGIConf
- type GslbBasicConf
- type HashConf
Constants ¶
const ( RetryConnect = 0 // retry if connect backend fail RetryGet = 1 // retry if forward GET request fail (plus RetryConnect) )
RetryLevels
const ( DefaultReadClientTimeout = 30000 DefaultWriteClientTimeout = 60000 DefaultReadClientAgainTimeout = 60000 )
DefaultTimeout
const ( // Abnormal events about backend: // - connect backend error // - write request error(caused by backend) // - read response header error OutlierDetectionBasic = 0 // All abnormal events in basic level and: // - response code is 5xx OutlierDetection5XX = 1 )
Outlier detection levels
const ( ClientIdOnly = iota // use CLIENTID to hash ClientIpOnly // use CLIENTIP to hash ClientIdPreferred // use CLIENTID to hash, otherwise use CLIENTIP )
HashStrategy for subcluster-level load balance (GSLB). Note:
- CLIENTID is a special request header which represents a unique client, eg. baidu id, passport id, device id etc.
const ( BalanceModeWrr = "WRR" // weighted round robin BalanceModeWlc = "WLC" // weighted least connection )
BALANCE_MODE used for GslbBasicConf.
const ( // AnyStatusCode is a special status code used in health-check. // If AnyStatusCode is used, any status code is acceptd for health-check response. AnyStatusCode = 0 )
Variables ¶
This section is empty.
Functions ¶
func BackendBasicCheck ¶
func BackendBasicCheck(conf *BackendBasic) error
BackendBasicCheck check BackendBasic config.
func BackendCheckCheck ¶
func BackendCheckCheck(conf *BackendCheck) error
BackendCheckCheck check BackendCheck config.
func BfeClusterConfCheck ¶
func BfeClusterConfCheck(conf *BfeClusterConf) error
BfeClusterConfCheck check integrity of config
func ClusterBasicConfCheck ¶
func ClusterBasicConfCheck(conf *ClusterBasicConf) error
ClusterBasicConfCheck check ClusterBasicConf.
func ClusterConfCheck ¶
func ClusterConfCheck(conf *ClusterConf) error
ClusterConfCheck check ClusterConf.
func ClusterToConfCheck ¶
func ClusterToConfCheck(conf ClusterToConf) error
ClusterToConfCheck check ClusterToConf.
func GetCookieKey ¶
func GslbBasicConfCheck ¶
func GslbBasicConfCheck(conf *GslbBasicConf) error
GslbBasicConfCheck check GslbBasicConf config.
Types ¶
type BackendBasic ¶
type BackendBasic struct { Protocol *string // backend protocol TimeoutConnSrv *int // timeout for connect backend, in ms TimeoutResponseHeader *int // timeout for read header from backend, in ms MaxIdleConnsPerHost *int // max idle conns for each backend RetryLevel *int // retry level if request fail OutlierDetectionLevel *int // outlier detection level // protocol specific configurations FCGIConf *FCGIConf }
BackendBasic is conf of backend basic
type BackendCheck ¶
type BackendCheck struct { Schem *string // protocol for health check (HTTP/TCP) Uri *string // uri used in health check Host *string // if check request use special host header StatusCode *int // default value is 200 FailNum *int // unhealthy threshold (consecutive failures of check request) SuccNum *int // healthy threshold (consecutive successes of normal request) CheckTimeout *int // timeout for health check, in ms CheckInterval *int // interval of health check, in ms }
BackendCheck is conf of backend check
type BfeClusterConf ¶
type BfeClusterConf struct { Version *string // version of config Config *ClusterToConf }
BfeClusterConf is conf of all bfe cluster.
func ClusterConfLoad ¶
func ClusterConfLoad(filename string) (BfeClusterConf, error)
ClusterConfLoad load config of cluster conf from file
func (*BfeClusterConf) LoadAndCheck ¶
func (conf *BfeClusterConf) LoadAndCheck(filename string) (string, error)
type ClusterBasicConf ¶
type ClusterBasicConf struct { TimeoutReadClient *int // timeout for read client body in ms TimeoutWriteClient *int // timeout for write response to client TimeoutReadClientAgain *int // timeout for read client again in ms ReqWriteBufferSize *int // write buffer size for request in byte ReqFlushInterval *int // interval to flush request in ms. if zero, disable periodic flush ResFlushInterval *int // interval to flush response in ms. if zero, disable periodic flush CancelOnClientClose *bool // cancel blocking operation on server if client connection disconnected }
ClusterBasicConf is basic conf for cluster.
type ClusterConf ¶
type ClusterConf struct { BackendConf *BackendBasic // backend's basic conf CheckConf *BackendCheck // how to check backend GslbBasic *GslbBasicConf // gslb basic conf for cluster ClusterBasic *ClusterBasicConf // basic conf for cluster }
ClusterConf is conf of cluster.
type ClusterToConf ¶
type ClusterToConf map[string]ClusterConf
type FCGIConf ¶ added in v0.12.0
type FCGIConf struct { EnvVars map[string]string // the vars which will send to backend Root string // the server root }
FastCGI related configurations
type GslbBasicConf ¶
type GslbBasicConf struct { CrossRetry *int // retry cross sub clusters RetryMax *int // inner cluster retry HashConf *HashConf BalanceMode *string // balanceMode, default WRR }
GslbBasicConf is basic conf for Gslb
type HashConf ¶
type HashConf struct { // HashStrategy is hash strategy for subcluster-level load balance. // ClientIdOnly, ClientIpOnly, ClientIdPreferred. HashStrategy *int // HashHeader is an optional request header which represents a unique client. // format for speicial cookie header is "Cookie:Key". // eg, Dueros-Device-Id, Cookie:BAIDUID, Cookie:PASSPORTID, etc HashHeader *string // SessionSticky enable sticky session (ensures that all requests // from the user during the session are sent to the same backend) SessionSticky *bool }