优化代码

This commit is contained in:
GoEdgeLab
2022-11-23 20:13:34 +08:00
parent a86055ac44
commit 96e80fb8cd
2 changed files with 15 additions and 16 deletions

View File

@@ -262,7 +262,12 @@ func (this *RPCClient) pickConn() *grpc.ClientConn {
defer this.locker.Unlock()
// 检查连接状态
if len(this.conns) > 0 {
var countConns = len(this.conns)
if countConns > 0 {
if countConns == 1 {
return this.conns[0]
}
for _, stateArray := range [][2]connectivity.State{
{connectivity.Ready, connectivity.Idle}, // 优先Ready和Idle
{connectivity.Connecting, connectivity.Connecting},