proxy

package
v0.0.0-...-d744151 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultDialTimeout when connecting to a backend server.
	DefaultDialTimeout = 30 * time.Second

	// DefaultIdleConnsPerHost the default value set for http.Transport.MaxIdleConnsPerHost.
	// krakend is 250 / janus is 64
	DefaultMaxIdleConnsPerHost = 250

	// DefaultIdleConnTimeout is the default value for the the maximum amount of time an idle
	// (keep-alive) connection will remain idle before closing itself.
	DefaultIdleConnTimeout = 90 * time.Second
)

Variables

This section is empty.

Functions

func NewProxyHandler

func NewProxyHandler(transport http.RoundTripper, director Director,
	modifyResponse ModifyResponse, errorHandler ErrorHandler,
) http.Handler

func NewTransport

func NewTransport(t TransportOption) *http.Transport

TODO: 有没有必要加register, 复用transport. save newly created transport in registry, to try to reuse it in the future New creates a new instance of Transport with the given params

Types

type Director

type Director func(req *http.Request)

type ErrorHandler

type ErrorHandler func(http.ResponseWriter, *http.Request, error)

type LoadBalancer

type LoadBalancer interface {
	Next() string
}

type ModifyResponse

type ModifyResponse func(*http.Response) error

type RRLoadBalance

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

SingleLoadBalance for the backend with multi hosts(with weight or not), will do smooth-RR

func NewRRLoadBalance

func NewRRLoadBalance(servers []string) *RRLoadBalance

func NewWeightedRRLoadBalance

func NewWeightedRRLoadBalance(servers map[string]int) *RRLoadBalance

func (*RRLoadBalance) Next

func (rr *RRLoadBalance) Next() string

type SingleLoadBalance

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

SingleLoadBalance for the backend with only one host

func NewSingleLoadBalance

func NewSingleLoadBalance(server string) *SingleLoadBalance

func (*SingleLoadBalance) Next

func (lb *SingleLoadBalance) Next() string

type TransportOption

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

type TransportOptionBuilder

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

func (*TransportOptionBuilder) Build

func (*TransportOptionBuilder) WithDialTimeout

WithDialTimeout sets the dial context timeout

func (*TransportOptionBuilder) WithIdleConnTimeout

func (ob *TransportOptionBuilder) WithIdleConnTimeout(d time.Duration) *TransportOptionBuilder

WithIdleConnTimeout sets the maximum amount of time an idle (keep-alive) connection will remain idle before closing itself.

func (*TransportOptionBuilder) WithInsecureSkipVerify

func (ob *TransportOptionBuilder) WithInsecureSkipVerify(value bool) *TransportOptionBuilder

WithInsecureSkipVerify sets tls config insecure skip verify

func (*TransportOptionBuilder) WithMaxIdleConnectionsPerHost

func (ob *TransportOptionBuilder) WithMaxIdleConnectionsPerHost(value int) *TransportOptionBuilder

Same as net/http.Transport.MaxIdleConnsPerHost, but the default is 64. This value supports scenarios with relatively few remote hosts. When the routing table contains different hosts in the range of hundreds, it is recommended to set this options to a lower value.

func (*TransportOptionBuilder) WithResponseHeaderTimeout

func (ob *TransportOptionBuilder) WithResponseHeaderTimeout(d time.Duration) *TransportOptionBuilder

WithResponseHeaderTimeout sets the response header timeout

Jump to

Keyboard shortcuts

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