Пример #1
0
func NewProxy(tr http.RoundTripper, cfg config.Proxy) *Proxy {
	return &Proxy{
		tr:       tr,
		cfg:      cfg,
		requests: gometrics.GetOrRegisterTimer("requests", gometrics.DefaultRegistry),
	}
}
Пример #2
0
func New(tr http.RoundTripper, cfg config.Proxy) *Proxy {
	return &Proxy{
		httpProxy: newHTTPProxy(tr, cfg),
		wsProxy:   newWSProxy(),
		requests:  gometrics.GetOrRegisterTimer("requests", gometrics.DefaultRegistry),
	}
}
Пример #3
0
func NewProxy(tr http.RoundTripper, clientIPHeader, tlsHeader, tlsHeaderValue string) *Proxy {
	return &Proxy{
		tr:             tr,
		clientIPHeader: clientIPHeader,
		tlsHeader:      tlsHeader,
		tlsHeaderValue: tlsHeaderValue,
		requests:       gometrics.GetOrRegisterTimer("requests", gometrics.DefaultRegistry),
	}
}
Пример #4
0
func (r *route) addTarget(service string, targetURL *url.URL, fixedWeight float64, tags []string) {
	if fixedWeight < 0 {
		fixedWeight = 0
	}

	name := metrics.TargetName(service, r.host, r.path, targetURL)
	timer := gometrics.GetOrRegisterTimer(name, gometrics.DefaultRegistry)

	t := &Target{service: service, tags: tags, URL: targetURL, fixedWeight: fixedWeight, Timer: timer}
	r.targets = append(r.targets, t)
	r.weighTargets()
}