cluster_conf

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 11, 2022 License: Apache-2.0 Imports: 5 Imported by: 2

Documentation

Index

Constants

View Source
const (
	RetryConnect = 0 // retry if connect backend fail
	RetryGet     = 1 // retry if forward GET request fail (plus RetryConnect)
)

RetryLevels

View Source
const (
	DefaultReadClientTimeout      = 30000
	DefaultWriteClientTimeout     = 60000
	DefaultReadClientAgainTimeout = 60000
)

DefaultTimeout

View Source
const (
	ClientIdOnly      = iota // use CLIENTID to hash
	ClientIpOnly             // use CLIENTIP to hash
	ClientIdPreferred        // use CLIENTID to hash, otherwise use CLIENTIP
	RequestURI               // use request URI to hash
)

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.
View Source
const (
	BalanceModeWrr = "WRR" // weighted round robin
	BalanceModeWlc = "WLC" // weighted least connection
)

BALANCE_MODE used for GslbBasicConf.

View Source
const (
	// AnyStatusCode is a special status code used in health-check.
	// If AnyStatusCode is used, any status code is accepted 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 GetCookieKey(header string) (string, bool)

func GslbBasicConfCheck

func GslbBasicConfCheck(conf *GslbBasicConf) error

GslbBasicConfCheck check GslbBasicConf config.

func HashConfCheck

func HashConfCheck(conf *HashConf) error

HashConfCheck check HashConf config.

func MatchStatusCode

func MatchStatusCode(statusCodeGet int, statusCodeExpect int) (bool, error)

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
	MaxConnsPerHost          *int    // max conns for each backend (zero means unrestricted)
	RetryLevel               *int    // retry level if request fail
	SlowStartTime            *int    // time for backend increases the weight to the full value, in seconds
	OutlierDetectionHttpCode *string // outlier detection http status code
	// 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, RequestURI.
	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
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL