diff --git a/balancer/balancer.go b/balancer/balancer.go index 3a2092f1056e..324915c1692f 100644 --- a/balancer/balancer.go +++ b/balancer/balancer.go @@ -155,6 +155,9 @@ type SubConn interface { // indicate the shutdown operation. This may be delivered before // in-progress RPCs are complete and the actual connection is closed. Shutdown() + // enforceEmbedding is an unexported method to force implementers embed + // this interface, allowing gRPC to add methods without breaking users. + enforceEmbedding() } // NewSubConnOptions contains options to create new SubConn. diff --git a/balancer/base/balancer_test.go b/balancer/base/balancer_test.go index ea868f29245d..ea4a4fda2493 100644 --- a/balancer/base/balancer_test.go +++ b/balancer/base/balancer_test.go @@ -41,6 +41,7 @@ func (c *testClientConn) NewSubConn(addrs []resolver.Address, opts balancer.NewS func (c *testClientConn) UpdateState(balancer.State) {} type testSubConn struct { + balancer.SubConn updateState func(balancer.SubConnState) } diff --git a/balancer_wrapper.go b/balancer_wrapper.go index 2a4f2878aef4..80620d31093d 100644 --- a/balancer_wrapper.go +++ b/balancer_wrapper.go @@ -254,6 +254,7 @@ func (ccb *ccBalancerWrapper) Target() string { // acBalancerWrapper is a wrapper on top of ac for balancers. // It implements balancer.SubConn interface. type acBalancerWrapper struct { + balancer.SubConn ac *addrConn // read-only ccb *ccBalancerWrapper // read-only stateListener func(balancer.SubConnState) diff --git a/internal/testutils/balancer.go b/internal/testutils/balancer.go index 80021903df3c..423e8d25f2f2 100644 --- a/internal/testutils/balancer.go +++ b/internal/testutils/balancer.go @@ -32,6 +32,7 @@ import ( // TestSubConn implements the SubConn interface, to be used in tests. type TestSubConn struct { + balancer.SubConn tcc *BalancerClientConn // the CC that owns this SubConn id string ConnectCh chan struct{}