xds: Rename xdsclientWrapper type to xdsClientWrapper in EDS. (#3896)

This commit is contained in:
Easwar Swaminathan 2020-09-21 16:59:02 -07:00 committed by GitHub
parent 924b48b046
commit d81def4352
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 18 deletions

View File

@ -39,7 +39,7 @@ const (
)
var (
newEDSBalancer = func(cc balancer.ClientConn, enqueueState func(priorityType, balancer.State), xdsClient *xdsclientWrapper, logger *grpclog.PrefixLogger) edsBalancerImplInterface {
newEDSBalancer = func(cc balancer.ClientConn, enqueueState func(priorityType, balancer.State), xdsClient *xdsClientWrapper, logger *grpclog.PrefixLogger) edsBalancerImplInterface {
return newEDSBalancerImpl(cc, enqueueState, xdsClient, logger)
}
)
@ -112,7 +112,7 @@ type edsBalancer struct {
xdsClientUpdate chan *edsUpdate
childPolicyUpdate *buffer.Unbounded
client *xdsclientWrapper // may change when passed a different service config
client *xdsClientWrapper // may change when passed a different service config
config *EDSConfig // may change when passed a different service config
edsImpl edsBalancerImplInterface
}

View File

@ -63,7 +63,7 @@ type balancerGroupWithConfig struct {
type edsBalancerImpl struct {
cc balancer.ClientConn
logger *grpclog.PrefixLogger
xdsClient *xdsclientWrapper // To fetch the load.Store from.
xdsClient *xdsClientWrapper // To fetch the load.Store from.
enqueueChildBalancerStateUpdate func(priorityType, balancer.State)
@ -98,7 +98,7 @@ type edsBalancerImpl struct {
}
// newEDSBalancerImpl create a new edsBalancerImpl.
func newEDSBalancerImpl(cc balancer.ClientConn, enqueueState func(priorityType, balancer.State), xdsClient *xdsclientWrapper, logger *grpclog.PrefixLogger) *edsBalancerImpl {
func newEDSBalancerImpl(cc balancer.ClientConn, enqueueState func(priorityType, balancer.State), xdsClient *xdsClientWrapper, logger *grpclog.PrefixLogger) *edsBalancerImpl {
edsImpl := &edsBalancerImpl{
cc: cc,
logger: logger,

View File

@ -696,7 +696,7 @@ func (s) TestEDS_LoadReport(t *testing.T) {
// implements the LoadStore() method to return the underlying load.Store to
// be used.
loadStore := &load.Store{}
cw := &xdsclientWrapper{
cw := &xdsClientWrapper{
xdsClient: &loadStoreWrapper{ls: loadStore},
}

View File

@ -229,7 +229,7 @@ func waitForNewEDSLB(t *testing.T, ch *testutils.Channel) *fakeEDSBalancer {
// cleanup.
func setup(edsLBCh *testutils.Channel, xdsClientCh *testutils.Channel) func() {
origNewEDSBalancer := newEDSBalancer
newEDSBalancer = func(cc balancer.ClientConn, enqueue func(priorityType, balancer.State), _ *xdsclientWrapper, logger *grpclog.PrefixLogger) edsBalancerImplInterface {
newEDSBalancer = func(cc balancer.ClientConn, enqueue func(priorityType, balancer.State), _ *xdsClientWrapper, logger *grpclog.PrefixLogger) edsBalancerImplInterface {
edsLB := newFakeEDSBalancer(cc)
defer func() { edsLBCh.Send(edsLB) }()
return edsLB

View File

@ -45,10 +45,10 @@ var (
bootstrapConfigNew = bootstrap.NewConfig
)
// xdsclientWrapper is responsible for getting the xds client from attributes or
// xdsClientWrapper is responsible for getting the xds client from attributes or
// creating a new xds client, and start watching EDS. The given callbacks will
// be called with EDS updates or errors.
type xdsclientWrapper struct {
type xdsClientWrapper struct {
logger *grpclog.PrefixLogger
newEDSUpdate func(xdsclient.EndpointsUpdate, error)
@ -77,8 +77,8 @@ type xdsclientWrapper struct {
//
// The given callbacks won't be called until the underlying xds_client is
// working and sends updates.
func newXDSClientWrapper(newEDSUpdate func(xdsclient.EndpointsUpdate, error), bbo balancer.BuildOptions, logger *grpclog.PrefixLogger) *xdsclientWrapper {
return &xdsclientWrapper{
func newXDSClientWrapper(newEDSUpdate func(xdsclient.EndpointsUpdate, error), bbo balancer.BuildOptions, logger *grpclog.PrefixLogger) *xdsClientWrapper {
return &xdsClientWrapper{
logger: logger,
newEDSUpdate: newEDSUpdate,
bbo: bbo,
@ -93,7 +93,7 @@ func newXDSClientWrapper(newEDSUpdate func(xdsclient.EndpointsUpdate, error), bb
// attributes), it will be closed.
//
// It returns whether xdsClient is replaced.
func (c *xdsclientWrapper) replaceXDSClient(newClient xdsClientInterface, newBalancerName string) bool {
func (c *xdsClientWrapper) replaceXDSClient(newClient xdsClientInterface, newBalancerName string) bool {
if c.xdsClient == newClient {
return false
}
@ -122,7 +122,7 @@ func (c *xdsclientWrapper) replaceXDSClient(newClient xdsClientInterface, newBal
// the balancerName (from bootstrap file or from service config) changed.
// - if balancer names are the same, do nothing, and return false
// - if balancer names are different, create new one, and return true
func (c *xdsclientWrapper) updateXDSClient(config *EDSConfig, attr *attributes.Attributes) bool {
func (c *xdsClientWrapper) updateXDSClient(config *EDSConfig, attr *attributes.Attributes) bool {
if attr != nil {
if clientFromAttr, _ := attr.Value(xdsinternal.XDSClientID).(xdsClientInterface); clientFromAttr != nil {
// This will also clear balancerName, to indicate that client is
@ -167,7 +167,7 @@ func (c *xdsclientWrapper) updateXDSClient(config *EDSConfig, attr *attributes.A
//
// This usually means load report needs to be restarted, but this function does
// NOT do that. Caller needs to call startLoadReport separately.
func (c *xdsclientWrapper) startEndpointsWatch(nameToWatch string) {
func (c *xdsClientWrapper) startEndpointsWatch(nameToWatch string) {
if c.xdsClient == nil {
return
}
@ -193,7 +193,7 @@ func (c *xdsclientWrapper) startEndpointsWatch(nameToWatch string) {
// Caller can cal this when the loadReportServer name changes, but
// edsServiceName doesn't (so we only need to restart load reporting, not EDS
// watch).
func (c *xdsclientWrapper) startLoadReport(edsServiceNameBeingWatched string, loadReportServer *string) {
func (c *xdsClientWrapper) startLoadReport(edsServiceNameBeingWatched string, loadReportServer *string) {
if c.xdsClient == nil {
c.logger.Warningf("xds: xdsClient is nil when trying to start load reporting. This means xdsClient wasn't passed in from the resolver, and xdsClient.New failed")
return
@ -207,7 +207,7 @@ func (c *xdsclientWrapper) startLoadReport(edsServiceNameBeingWatched string, lo
}
}
func (c *xdsclientWrapper) loadStore() *load.Store {
func (c *xdsClientWrapper) loadStore() *load.Store {
if c == nil || c.xdsClient == nil {
return nil
}
@ -216,7 +216,7 @@ func (c *xdsclientWrapper) loadStore() *load.Store {
// handleUpdate applies the service config and attributes updates to the client,
// including updating the xds_client to use, and updating the EDS name to watch.
func (c *xdsclientWrapper) handleUpdate(config *EDSConfig, attr *attributes.Attributes) {
func (c *xdsClientWrapper) handleUpdate(config *EDSConfig, attr *attributes.Attributes) {
clientChanged := c.updateXDSClient(config, attr)
var (
@ -254,7 +254,7 @@ func (c *xdsclientWrapper) handleUpdate(config *EDSConfig, attr *attributes.Attr
}
}
func (c *xdsclientWrapper) cancelWatch() {
func (c *xdsClientWrapper) cancelWatch() {
c.loadReportServer = nil
if c.cancelLoadReport != nil {
c.cancelLoadReport()
@ -265,7 +265,7 @@ func (c *xdsclientWrapper) cancelWatch() {
}
}
func (c *xdsclientWrapper) close() {
func (c *xdsClientWrapper) close() {
c.cancelWatch()
if c.xdsClient != nil && c.balancerName != "" {
// Only close xdsClient if it's not from attributes.