Skip to content

Commit 001f394

Browse files
committed
Improve Stringer interface on acBalancerWrapper to allow human identification of which SubConn is used
Protect access to curAddr with ac.mutex Signed-off-by: Yolan Romailler <[email protected]>
1 parent 1b86b6d commit 001f394

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

balancer_wrapper.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,9 @@ func (acbw *acBalancerWrapper) updateState(s connectivity.State, err error) {
261261
}
262262

263263
func (acbw *acBalancerWrapper) String() string {
264-
return fmt.Sprintf("SubConn(id:%d)", acbw.ac.channelz.ID)
264+
acbw.ac.mu.Lock()
265+
defer acbw.ac.mu.Unlock()
266+
return fmt.Sprintf("SubConn(id:%d;addr:%s)", acbw.ac.channelz.ID, acbw.ac.curAddr.Addr)
265267
}
266268

267269
func (acbw *acBalancerWrapper) UpdateAddresses(addrs []resolver.Address) {

0 commit comments

Comments
 (0)