Documentation
¶
Index ¶
- Constants
- func GetAttemptsFromContext(r *http.Request) int
- func GetRetryFromContext(r *http.Request) int
- func ReadLines(path string) ([]string, error)
- type Algorithm
- type Backend
- type Config
- type ServerPool
- func (s *ServerPool) AddBackend(backend *Backend)
- func (s *ServerPool) GetHighestWeight() *Backend
- func (s *ServerPool) GetLowestLatency() *Backend
- func (s *ServerPool) GetNextPeer() *Backend
- func (s *ServerPool) HealthCheck()
- func (s *ServerPool) InitConnections() map[string]int
- func (s *ServerPool) MarkBackendStatus(backendUrl *url.URL, alive bool)
- func (s *ServerPool) NextIndex() int
Constants ¶
View Source
const ( Attempts int = iota Retry )
Variables ¶
This section is empty.
Functions ¶
func GetAttemptsFromContext ¶
func GetRetryFromContext ¶
Types ¶
type Backend ¶
type Backend struct {
URL *url.URL
Alive bool
ReverseProxy *httputil.ReverseProxy
Latency int64
Weight float64
Connections int
// contains filtered or unexported fields
}
func (*Backend) SetLatency ¶
type Config ¶
type Config struct {
Algorithm Algorithm `yaml:"algorithm"`
Port int `yaml:"port"`
Strict bool `yaml:"strict"`
Log bool `yaml:"log"`
XssProtection bool `yaml:"xss-protection"`
AccessControlAllowOrigin string `yaml:"access-control-allow-origin"`
MaxBodySize int `yaml:"max-body-size"`
Servers []struct {
Host string `yaml:"host"`
Weight float64 `yaml:"weight"`
Connections int `yaml:"connections"`
} `yaml:"servers"`
}
type ServerPool ¶
type ServerPool struct {
// contains filtered or unexported fields
}
func (*ServerPool) AddBackend ¶
func (s *ServerPool) AddBackend(backend *Backend)
func (*ServerPool) GetHighestWeight ¶
func (s *ServerPool) GetHighestWeight() *Backend
func (*ServerPool) GetLowestLatency ¶
func (s *ServerPool) GetLowestLatency() *Backend
func (*ServerPool) GetNextPeer ¶
func (s *ServerPool) GetNextPeer() *Backend
func (*ServerPool) HealthCheck ¶
func (s *ServerPool) HealthCheck()
func (*ServerPool) InitConnections ¶
func (s *ServerPool) InitConnections() map[string]int
func (*ServerPool) MarkBackendStatus ¶
func (s *ServerPool) MarkBackendStatus(backendUrl *url.URL, alive bool)
func (*ServerPool) NextIndex ¶
func (s *ServerPool) NextIndex() int
Click to show internal directories.
Click to hide internal directories.