fix/resolver-weight-0
baozhecheng 2 years ago
parent 70535dc751
commit 05b5928114
  1. 2
      transport/grpc/resolver/discovery/resolver.go
  2. 2
      transport/http/resolver.go

@ -68,7 +68,7 @@ func (r *discoveryResolver) update(ins []*registry.ServiceInstance) {
continue continue
} }
// filter weight <= 0 // filter weight <= 0
if w, ok := in.Metadata["weight"]; ok { if w, ok := in.Metadata["weight"]; ok && w != "" {
if i, err := strconv.ParseInt(w, 10, 64); err == nil && i <= 0 { if i, err := strconv.ParseInt(w, 10, 64); err == nil && i <= 0 {
continue continue
} }

@ -132,7 +132,7 @@ func (r *resolver) update(services []*registry.ServiceInstance) bool {
continue continue
} }
// filter weight <= 0 // filter weight <= 0
if w, ok := ins.Metadata["weight"]; ok { if w, ok := ins.Metadata["weight"]; ok && w != "" {
if i, err := strconv.ParseInt(w, 10, 64); err == nil && i <= 0 { if i, err := strconv.ParseInt(w, 10, 64); err == nil && i <= 0 {
continue continue
} }

Loading…
Cancel
Save