balancer: add ExitIdle optional interface (#4673)

This commit is contained in:
Doug Fawley
2021-08-18 15:04:35 -07:00
committed by GitHub
parent 52cea24534
commit 8ab16ef276
19 changed files with 231 additions and 32 deletions

View File

@ -555,13 +555,13 @@ func (cc *ClientConn) GetState() connectivity.State {
// Notice: This API is EXPERIMENTAL and may be changed or removed in a later
// release.
func (cc *ClientConn) Connect() {
if cc.GetState() == connectivity.Idle {
cc.mu.Lock()
for ac := range cc.conns {
// TODO: should this be a signal to the LB policy instead?
go ac.connect()
}
cc.mu.Unlock()
cc.mu.Lock()
defer cc.mu.Unlock()
if cc.balancerWrapper != nil && cc.balancerWrapper.exitIdle() {
return
}
for ac := range cc.conns {
go ac.connect()
}
}