lb

package
v1.3.5 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2022 License: MIT Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
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

func GetAttempts(r *http.Request) int

GetAttempts returns the attempts for request.

func GetRetry

func GetRetry(r *http.Request) int

GetRetry returns the retries for request.

func IsAddressAlive

func IsAddressAlive(address string) bool

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

func TimeoutDialContext

func TimeoutDialContext(rwtimeout, ctimeout time.Duration) fasthttp.DialFunc

TimeoutDialContext implements our own dialer in order to set read and write idle timeouts.

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

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

Alive returns true when backend is alive

func (*Backend) ParseAddress

func (b *Backend) ParseAddress(addr string) (err error)

ParseAddress parses an address to https, host(ip:port)

func (*Backend) SetAlive

func (b *Backend) SetAlive(alive bool)

SetAlive for this backend

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.

func MakeHeaderHop

func MakeHeaderHop() *HeaderHop

MakeHeaderHop makes a HeaderHop structure.

func (*HeaderHop) Del

func (h *HeaderHop) Del(reqHeader Deleter)

Del deletes the hopped headers.

type HeaderSaver

type HeaderSaver struct {
	// contains filtered or unexported fields
}

HeaderSaver provides a structure to save headers.

type Setter

type Setter interface {
	// set sets the given 'key: value' header.
	Set(key, value string)
}

Setter provides a set key:value func.

Jump to

Keyboard shortcuts

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