Skip to content

Commit

Permalink
Improve Stringer interface on acBalancerWrapper to allow human identi…
Browse files Browse the repository at this point in the history
…fication of which SubConn is used

Protect access to curAddr with ac.mutex

Signed-off-by: Yolan Romailler <anomalroil@users.noreply.github.com>
  • Loading branch information
AnomalRoil committed Apr 22, 2024
1 parent 1b86b6d commit 001f394
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion balancer_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,9 @@ func (acbw *acBalancerWrapper) updateState(s connectivity.State, err error) {
}

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

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

0 comments on commit 001f394

Please sign in to comment.