Documentation ¶
Index ¶
- Constants
- func NewProxyHandler(transport http.RoundTripper, director Director, modifyResponse ModifyResponse, ...) http.Handler
- func NewTransport(t TransportOption) *http.Transport
- type Director
- type ErrorHandler
- type LoadBalancer
- type ModifyResponse
- type RRLoadBalance
- type SingleLoadBalance
- type TransportOption
- type TransportOptionBuilder
- func (ob *TransportOptionBuilder) Build() TransportOption
- func (ob *TransportOptionBuilder) WithDialTimeout(d time.Duration) *TransportOptionBuilder
- func (ob *TransportOptionBuilder) WithIdleConnTimeout(d time.Duration) *TransportOptionBuilder
- func (ob *TransportOptionBuilder) WithInsecureSkipVerify(value bool) *TransportOptionBuilder
- func (ob *TransportOptionBuilder) WithMaxIdleConnectionsPerHost(value int) *TransportOptionBuilder
- func (ob *TransportOptionBuilder) WithResponseHeaderTimeout(d time.Duration) *TransportOptionBuilder
Constants ¶
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 ErrorHandler ¶
type ErrorHandler func(http.ResponseWriter, *http.Request, error)
type LoadBalancer ¶
type LoadBalancer interface {
Next() string
}
type ModifyResponse ¶
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 (ob *TransportOptionBuilder) Build() TransportOption
func (*TransportOptionBuilder) WithDialTimeout ¶
func (ob *TransportOptionBuilder) WithDialTimeout(d time.Duration) *TransportOptionBuilder
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