diff --git a/lego/sys/rpcx/client.go b/lego/sys/rpcx/client.go index d6e888d03..b10af1153 100644 --- a/lego/sys/rpcx/client.go +++ b/lego/sys/rpcx/client.go @@ -333,16 +333,16 @@ func (this *Client) getclient(ctx *context.Context, clusterTag string, servicePa if d, err = client.NewConsulDiscovery(clusterTag, spath[0], this.options.ConsulServers, nil); err != nil { return } - c = client.NewBidirectionalXClient(spath[0], client.Failfast, client.RandomSelect, d, client.DefaultOption, this.msgChan) + c = client.NewBidirectionalXClient(spath[0], client.Failfast, client.RoundRobin, d, client.DefaultOption, this.msgChan) cluster.Mu.Lock() cluster.clients[spath[0]] = c cluster.Mu.Unlock() c.GetPlugins().Add(this) - if this.options.RpcxStartType == RpcxStartByClient && this.options.AutoConnect { - c.SetSelector(newSelector(this.options.Log, clusterTag, this.UpdateServer)) - } else { - c.SetSelector(newSelector(this.options.Log, clusterTag, nil)) - } + // if this.options.RpcxStartType == RpcxStartByClient && this.options.AutoConnect { + c.SetSelector(newSelector(this.options.Log, clusterTag, this.UpdateServer)) + // } else { + // c.SetSelector(newSelector(this.options.Log, clusterTag, nil)) + // } } *ctx = context.WithValue(*ctx, share.ReqMetaDataKey, map[string]string{ diff --git a/lego/sys/rpcx/selector.go b/lego/sys/rpcx/selector.go index 363ae7de6..7023ba4e5 100644 --- a/lego/sys/rpcx/selector.go +++ b/lego/sys/rpcx/selector.go @@ -103,11 +103,11 @@ func (this *Selector) UpdateServer(servers map[string]string) { continue } else { ss[node.ServiceId] = node - if ssts, ok := sst[node.ServiceType]; !ok { + if _, ok := sst[node.ServiceType]; !ok { sst[node.ServiceType] = make([]*ServiceNode, 0) sst[node.ServiceType] = append(sst[node.ServiceType], node) } else { - ssts = append(ssts, node) + sst[node.ServiceType] = append(sst[node.ServiceType], node) } }