INNER CODE UNIT · Go

nodeWeight

go-kratos/gateway · client/factory.go:134

func nodeWeight(n *registry.ServiceInstance) *int64 {
	w, ok := n.Metadata["weight"]
	if ok {
		val, _ := strconv.ParseInt(w, 10, 64)
		if val <= 0 {
			return &_defaultWeight
		}
		return &val
	}
	return &_defaultWeight
}

func (na *nodeApplier) Callback(services []*registry.ServiceInstance) error {
	if atomic.LoadInt64(&na.canceled) == 1 {
		return ErrCancelWatch
	}
	if len(services) == 0 {
		return nil

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…