Exemple #1
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()
}
Exemple #2
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, metrics.ServiceRegistry)

	t := &Target{Service: service, Tags: tags, URL: targetURL, FixedWeight: fixedWeight, Timer: timer, timerName: name}
	r.Targets = append(r.Targets, t)
	r.weighTargets()
}
Exemple #3
0
func (r *Route) addTarget(service string, targetURL *url.URL, fixedWeight float64, tags []string) {
	if fixedWeight < 0 {
		fixedWeight = 0
	}

	name, err := metrics.TargetName(service, r.Host, r.Path, targetURL)
	if err != nil {
		log.Printf("[ERROR] Invalid metrics name: %s", err)
		name = "unknown"
	}
	timer := ServiceRegistry.GetTimer(name)

	t := &Target{Service: service, Tags: tags, URL: targetURL, FixedWeight: fixedWeight, Timer: timer, timerName: name}
	r.Targets = append(r.Targets, t)
	r.weighTargets()
}
Exemple #4
0
func (r *Route) addTarget(service string, targetURL *url.URL, fixedWeight float64, tags []string) {
	if fixedWeight < 0 {
		fixedWeight = 0
	}

	// de-dup existing target
	for _, t := range r.Targets {
		if t.Service == service && t.URL.String() == targetURL.String() && t.FixedWeight == fixedWeight && reflect.DeepEqual(t.Tags, tags) {
			return
		}
	}

	name, err := metrics.TargetName(service, r.Host, r.Path, targetURL)
	if err != nil {
		log.Printf("[ERROR] Invalid metrics name: %s", err)
		name = "unknown"
	}
	timer := ServiceRegistry.GetTimer(name)

	t := &Target{Service: service, Tags: tags, URL: targetURL, FixedWeight: fixedWeight, Timer: timer, timerName: name}
	r.Targets = append(r.Targets, t)
	r.weighTargets()
}