Documentation
¶
Index ¶
- Constants
- func GetAttempts(r *http.Request) int
- func GetRetry(r *http.Request) int
- func IsAddressAlive(address string) bool
- func ServeHTTP(w http.ResponseWriter, r *http.Request, h HandlerFunc) error
- func TimeoutDialContext(rwtimeout, ctimeout time.Duration) fasthttp.DialFunc
- type Backend
- type BackendPool
- type Deleter
- type HandlerFunc
- type HeaderHop
- type HeaderSaver
- type Setter
Constants ¶
const ( // Attempts represents the key of attempts times. Attempts key = iota // Retries represents the key of retry times. Retries )
Variables ¶
This section is empty.
Functions ¶
func GetAttempts ¶
GetAttempts returns the attempts for request.
func IsAddressAlive ¶
IsAddressAlive checks whether an address is alive by establishing a TCP connection
func ServeHTTP ¶
func ServeHTTP(w http.ResponseWriter, r *http.Request, h HandlerFunc) error
ServeHTTP ReverseProxy to serve ref to: https://golang.org/src/net/http/httputil/reverseproxy.go#L169
Types ¶
type Backend ¶
type Backend struct {
Host string // ip:port
Addr *url.URL
// contains filtered or unexported fields
}
Backend holds the data about a server
func (*Backend) ParseAddress ¶
ParseAddress parses an address to https, host(ip:port)
type BackendPool ¶
type BackendPool struct {
// contains filtered or unexported fields
}
BackendPool holds information about reachable backends
func CreateProxyServerPool ¶ added in v1.3.5
func CreateProxyServerPool(serverList string) *BackendPool
CreateProxyServerPool creates a server pool by serverList
func (*BackendPool) Add ¶
func (s *BackendPool) Add(backend *Backend)
Add adds a backend to the server pool
func (*BackendPool) CheckBackends ¶
func (s *BackendPool) CheckBackends() error
CheckBackends check backends
func (*BackendPool) GetNextPeer ¶
func (s *BackendPool) GetNextPeer() *Backend
GetNextPeer returns next active peer to take a connection
func (*BackendPool) HealthCheck ¶
func (s *BackendPool) HealthCheck()
HealthCheck runs a routine for check status of the backends every 20s
type Deleter ¶
type Deleter interface {
// Del deletes header with the given key.
Del(key string)
}
Deleter provides the ability to delete by key.
type HandlerFunc ¶
type HandlerFunc func(http.ResponseWriter, *http.Request) error
type HeaderHop ¶
type HeaderHop struct {
// contains filtered or unexported fields
}
HeaderHop provides the structure for headers to be hopped.
type HeaderSaver ¶
type HeaderSaver struct {
// contains filtered or unexported fields
}
HeaderSaver provides a structure to save headers.