mirror of https://github.com/grpc/grpc-go.git
balacergroup: cleanup exitIdle() (#8347)
This commit is contained in:
parent
e3ca7f9077
commit
4cab0e6dc6
|
@ -106,15 +106,14 @@ func (sbc *subBalancerWrapper) startBalancer() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// exitIdle invokes the sub-balancer's ExitIdle method. Returns a boolean
|
// exitIdle invokes the ExitIdle method on the sub-balancer, a gracefulswitch
|
||||||
// indicating whether or not the operation was completed.
|
// balancer.
|
||||||
func (sbc *subBalancerWrapper) exitIdle() (complete bool) {
|
func (sbc *subBalancerWrapper) exitIdle() {
|
||||||
b := sbc.balancer
|
b := sbc.balancer
|
||||||
if b == nil {
|
if b == nil {
|
||||||
return true
|
return
|
||||||
}
|
}
|
||||||
b.ExitIdle()
|
b.ExitIdle()
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sbc *subBalancerWrapper) updateClientConnState(s balancer.ClientConnState) error {
|
func (sbc *subBalancerWrapper) updateClientConnState(s balancer.ClientConnState) error {
|
||||||
|
@ -411,20 +410,6 @@ func (bg *BalancerGroup) cleanupSubConns(config *subBalancerWrapper) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// connect attempts to connect to all subConns belonging to sb.
|
|
||||||
func (bg *BalancerGroup) connect(sb *subBalancerWrapper) {
|
|
||||||
bg.incomingMu.Lock()
|
|
||||||
defer bg.incomingMu.Unlock()
|
|
||||||
if bg.incomingClosed {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
for sc, b := range bg.scToSubBalancer {
|
|
||||||
if b == sb {
|
|
||||||
sc.Connect()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Following are actions from the parent grpc.ClientConn, forward to sub-balancers.
|
// Following are actions from the parent grpc.ClientConn, forward to sub-balancers.
|
||||||
|
|
||||||
// updateSubConnState forwards the update to cb and updates scToSubBalancer if
|
// updateSubConnState forwards the update to cb and updates scToSubBalancer if
|
||||||
|
@ -575,9 +560,7 @@ func (bg *BalancerGroup) ExitIdle() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, config := range bg.idToBalancerConfig {
|
for _, config := range bg.idToBalancerConfig {
|
||||||
if !config.exitIdle() {
|
config.exitIdle()
|
||||||
bg.connect(config)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -590,9 +573,7 @@ func (bg *BalancerGroup) ExitIdleOne(id string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if config := bg.idToBalancerConfig[id]; config != nil {
|
if config := bg.idToBalancerConfig[id]; config != nil {
|
||||||
if !config.exitIdle() {
|
config.exitIdle()
|
||||||
bg.connect(config)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue