revproxy

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientSession

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

type Dialer

type Dialer = func(ctx context.Context) (net.Conn, error)

type LbMethod

type LbMethod string
const (
	LbConn   LbMethod = "conn"
	LbRandom LbMethod = "random"
	LbHash   LbMethod = "hash"
)

type LoadBalancer

type LoadBalancer struct {
	Options
	Upstreams []*Upstream
	// contains filtered or unexported fields
}

func NewLoadBalancer

func NewLoadBalancer(opt Options) (lb *LoadBalancer)

func (*LoadBalancer) AddUpstream

func (lb *LoadBalancer) AddUpstream(u *Upstream)

func (*LoadBalancer) Close

func (lb *LoadBalancer) Close()

func (*LoadBalancer) Listen

func (lb *LoadBalancer) Listen() error

func (*LoadBalancer) Next

func (lb *LoadBalancer) Next(ip string, retry *Upstream) (us *Upstream)

func (*LoadBalancer) RemoveUpstream

func (lb *LoadBalancer) RemoveUpstream(u *Upstream)

func (*LoadBalancer) ServeHTTP

func (lb *LoadBalancer) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Options

type Options struct {
	Host         string                `json:"host"`        // The host header to set.
	Listen       string                `json:"listen"`      // The listen address.
	Sticky       bool                  `json:"sticky"`      // If true, the same upstream is chosen for the same client if possible.
	Method       LbMethod              `json:"method"`      // The load balancing method.
	RetryMax     int                   `json:"retry_max"`   // The maximum number of retries.
	RetryBackoff util.ParsableDuration `json:"retry_delay"` // The delay between retries.
}

type Upstream

type Upstream struct {
	Name        string
	DialContext Dialer
	// contains filtered or unexported fields
}

func NewIpcUpstream

func NewIpcUpstream(name string, address string) (u *Upstream)

func NewUpstream

func NewUpstream(name string, dialer Dialer) (u *Upstream)

func (*Upstream) ServeHTTP

func (p *Upstream) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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