优化代码

This commit is contained in:
刘祥超
2022-11-24 17:20:08 +08:00
parent 3a23b57f1b
commit 7786140d85
3 changed files with 7 additions and 6 deletions

View File

@@ -571,7 +571,11 @@ 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 _, state := range []connectivity.State{
connectivity.Ready,
connectivity.Idle,