|
|
@ -129,18 +129,23 @@ func (r *Resolver) updateproc() { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if ins, ok := r.nr.Fetch(context.Background()); ok { |
|
|
|
if ins, ok := r.nr.Fetch(context.Background()); ok { |
|
|
|
instances, ok := ins.Instances[r.zone] |
|
|
|
instances, _ := ins.Instances[r.zone] |
|
|
|
if !ok { |
|
|
|
res := r.filter(instances) |
|
|
|
|
|
|
|
if len(res) == 0 { |
|
|
|
for _, value := range ins.Instances { |
|
|
|
for _, value := range ins.Instances { |
|
|
|
instances = append(instances, value...) |
|
|
|
instances = append(instances, value...) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
res = r.filter(instances) |
|
|
|
} |
|
|
|
} |
|
|
|
r.newAddress(r.filter(instances)) |
|
|
|
r.newAddress(res) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (r *Resolver) filter(backends []*naming.Instance) (instances []*naming.Instance) { |
|
|
|
func (r *Resolver) filter(backends []*naming.Instance) (instances []*naming.Instance) { |
|
|
|
|
|
|
|
if len(backends) == 0 { |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
for _, ins := range backends { |
|
|
|
for _, ins := range backends { |
|
|
|
//如果r.clusters的长度大于0说明需要进行集群选择
|
|
|
|
//如果r.clusters的长度大于0说明需要进行集群选择
|
|
|
|
if _, ok := r.clusters[ins.Metadata[naming.MetaCluster]]; !ok && len(r.clusters) > 0 { |
|
|
|
if _, ok := r.clusters[ins.Metadata[naming.MetaCluster]]; !ok && len(r.clusters) > 0 { |
|
|
|