From 7840bd63dea893764c348d1a2cacc3dbfc766a56 Mon Sep 17 00:00:00 2001 From: Easwar Swaminathan Date: Mon, 21 Mar 2022 14:51:11 -0700 Subject: [PATCH] grpc: add a comment explaining why updateClientConnState is handled inline (#5261) --- balancer_conn_wrappers.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/balancer_conn_wrappers.go b/balancer_conn_wrappers.go index cb4b6728c22..84934bc0e67 100644 --- a/balancer_conn_wrappers.go +++ b/balancer_conn_wrappers.go @@ -167,6 +167,15 @@ func (ccb *ccBalancerWrapper) handleSubConnStateChange(sc balancer.SubConn, s co }) } +// updateClientConnState forwards the clientConn update to the wrapped balancer +// synchronously. +// +// Other calls from the channel like exitIdle() and handleSubConnStateChange() +// are handled asynchronously by pushing the update onto a channel, which is +// picked up by the watcher() goroutine and forwarded to the wrapped balancer. +// That approach cannot be taken here because the corresponding API on the +// balancer returns an error which needs to be sent back to the channel to be +// forward to the resolver. func (ccb *ccBalancerWrapper) updateClientConnState(ccs *balancer.ClientConnState) error { ccb.balancerMu.Lock() defer ccb.balancerMu.Unlock()