mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-20 00:39:01 +08:00
conn
This commit is contained in:
@@ -11,7 +11,10 @@ type RoundRobin struct {
|
||||
lock sync.Mutex
|
||||
}
|
||||
|
||||
func (r *RoundRobin) getConnBalance(conns []*grpc.ClientConn) (conn *grpc.ClientConn) {
|
||||
func (r *RoundRobin) getConnBalance(conns []*grpc.ClientConn) (conn *grpc.ClientConn, err error) {
|
||||
if len(conns) == 0 {
|
||||
return nil, ErrConnIsNil
|
||||
}
|
||||
r.lock.Lock()
|
||||
defer r.lock.Unlock()
|
||||
if r.index < len(conns)-1 {
|
||||
@@ -19,5 +22,5 @@ func (r *RoundRobin) getConnBalance(conns []*grpc.ClientConn) (conn *grpc.Client
|
||||
} else {
|
||||
r.index = 0
|
||||
}
|
||||
return conns[r.index]
|
||||
return conns[r.index], nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user