cmd

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Attempts int = iota
	Retry
)

Variables

This section is empty.

Functions

func GetAttemptsFromContext

func GetAttemptsFromContext(r *http.Request) int

func GetRetryFromContext

func GetRetryFromContext(r *http.Request) int

func ReadLines

func ReadLines(path string) ([]string, error)

Types

type Algorithm added in v0.0.7

type Algorithm string
const (
	LeastTime          Algorithm = "least-time"
	WeightedRoundRobin Algorithm = "weighted-round-robin"
	ConnectionPerTime  Algorithm = "connection-per-time"
	RoundRobin         Algorithm = "round-robin"
)

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) IsActive

func (b *Backend) IsActive() (alive bool)

func (*Backend) SetAlive

func (b *Backend) SetAlive(alive bool)

func (*Backend) SetLatency

func (b *Backend) SetLatency(latency int64)

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"`
}

func (*Config) GetConf

func (c *Config) GetConf() *Config

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

Jump to

Keyboard shortcuts

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