balancer: Enforce embedding the SubConn interface in implementations (#7758)

This commit is contained in:
Arjan Singh Bal 2024-11-05 23:22:26 +05:30 committed by GitHub
parent 2de6df9c6f
commit 43ee17261c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 6 additions and 0 deletions

View File

@ -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.

View File

@ -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)
}

View File

@ -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)

View File

@ -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{}