balacergroup: cleanup exitIdle()#8347
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #8347 +/- ##
==========================================
- Coverage 82.35% 82.28% -0.07%
==========================================
Files 419 419
Lines 42034 42039 +5
==========================================
- Hits 34615 34591 -24
- Misses 5968 5985 +17
- Partials 1451 1463 +12
🚀 New features to boost your workflow:
|
|
|
||
| // exitIdle invokes the sub-balancer's ExitIdle method. Returns a boolean | ||
| // exitIdle invokes the sub-balancer's ExitIdle method. Returns a true | ||
| // indicating whether or not the operation was completed. |
There was a problem hiding this comment.
nit) i suggest that whether or not to be whether.
| b.ExitIdle() | ||
| } | ||
| b.ExitIdle() | ||
| return true |
There was a problem hiding this comment.
oh.. return true * 2 😅 hard to understand code.. refactor +1!
eshitachandwani
left a comment
There was a problem hiding this comment.
Hey @hugehoo , thank you for the PR , I have a few suggestions since the code has changed.
Since the function only returns true , you can change it to not return anything and just call ExitIdle and also remove the condition in balancerGroup because it is never executed and the functionality of connecting to all subconns has been passed down to gracefulSwitch Balancer and since the balancer in subBalancerWrapper has been changed to gracefulSwitch balancer, it will always have ExitIdle function:
func (sbc *subBalancerWrapper) exitIdle(){
b := sbc.balancer
if b == nil {
return
}
b.ExitIdle()
}
And change the these parts as follows:
if config := bg.idToBalancerConfig[id]; config != nil {
config.exitIdle()
}
eshitachandwani
left a comment
There was a problem hiding this comment.
Also do add this to the description:
RELEASE NOTES: N/A
9db880d to
cdf756e
Compare
| // 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() | ||
| } | ||
| } | ||
| } | ||
|
|
eshitachandwani
left a comment
There was a problem hiding this comment.
nit) i suggest that
whether or notto bewhether.
Can you add a clarification in comments that the sub-balancer is a graceful switch balancer
| // exitIdle invokes the sub-balancer's ExitIdle method. Returns a boolean | ||
| // indicating whether or not the operation was completed. | ||
| func (sbc *subBalancerWrapper) exitIdle() (complete bool) { | ||
| // exitIdle invokes the sub-balancer's ExitIdle method. |
There was a problem hiding this comment.
Can you add a clarification in comments that the sub-balancer is a graceful switch balancer
eshitachandwani
left a comment
There was a problem hiding this comment.
LGTM modulo one minor comment , adding @arjan-bal for another review.
| // exitIdle invokes the sub-balancer's ExitIdle method | ||
| // which is a graceful switch balancer. |
There was a problem hiding this comment.
| // exitIdle invokes the sub-balancer's ExitIdle method | |
| // which is a graceful switch balancer. | |
| // exitIdle invokes the ExitIdle method on the sub-balancer, a gracefulswitch | |
| // balancer. |
|
LGTM, thanks for the cleanup! |

context
exitIdle()is called in both ExitIdle() and ExitIdleOne()it returns boolean value. if it returns false if-statement works.
But the current implementation of
exitIdle()is returning only true.As-Is
exitIdlemethod returns boolean type but implementation returns only true.To-be
so i simplified implementation as method only returns true.
And fixed comment too as
Returns a trueI'm not sure this refactoring is necessary but at least the comment on exitIdle seems to be updated.
RELEASE NOTES: N/A