func WithTimeout(d time.Duration) Option {
	return newFuncBuildOption(func(o *buildOption) {
		o.timeout = d
	})
}
WithTimeout specify the timeout of each request
package proxy
import (
	"crypto/tls"
	"time"
)
type Option interface {
	apply(o *buildOption)
}
type buildOption struct {
	openBalance bool
	weights []W
	addresses []string
	tlsConfig *tls.Config
	timeout time.Duration
}
type funcBuildOption struct {
	f func(o *buildOption)
}
func newFuncBuildOption(f func(o *buildOption)) funcBuildOption { return funcBuildOption{f: f} }
func (fb funcBuildOption) apply(o *buildOption)                 { fb.f(o) }
func WithTLSConfig(config *tls.Config) Option {
	return newFuncBuildOption(func(o *buildOption) {
		o.tlsConfig = config
	})
}
func WithTLS(certFile, keyFile string) Option {
	cert, err := tls.LoadX509KeyPair(certFile, keyFile)
	if err != nil {
		panic("" + err.Error())
	}
	return WithTLSConfig(&tls.Config{
		Certificates: []tls.Certificate{cert},
	})
}
func WithBalancer(addrWeights map[string]Weight) Option {
	weights := make([]W, 0, len(addrWeights))
	addresses := make([]string, 0, len(addrWeights))
	for k, v := range addrWeights {
		weights = append(weights, v)
		addresses = append(addresses, k)
	}
	return newFuncBuildOption(func(o *buildOption) {
		o.addresses = addresses
		o.openBalance = true
		o.weights = weights
	})
}