From 146eb77f4ee8a730dcfd90caf559f42addcd64a4 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Wed, 6 Sep 2023 18:26:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0rpcx=20=E8=B4=9F=E8=BD=BD?= =?UTF-8?q?=E5=9D=87=E8=A1=A1=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lego/sys/rpcx/client.go | 12 ++++++------ lego/sys/rpcx/selector.go | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) 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) } }