Skip to content

Commit

Permalink
xds: Rename xdsclientWrapper type to xdsClientWrapper in EDS. (#3896)
Browse files Browse the repository at this point in the history
  • Loading branch information
easwars committed Sep 21, 2020
1 parent 924b48b commit d81def4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions xds/internal/balancer/edsbalancer/eds.go
Expand Up @@ -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)
}
)
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions xds/internal/balancer/edsbalancer/eds_impl.go
Expand Up @@ -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)

Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion xds/internal/balancer/edsbalancer/eds_impl_test.go
Expand Up @@ -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},
}

Expand Down
2 changes: 1 addition & 1 deletion xds/internal/balancer/edsbalancer/eds_test.go
Expand Up @@ -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
Expand Down
24 changes: 12 additions & 12 deletions xds/internal/balancer/edsbalancer/xds_client_wrapper.go
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand All @@ -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
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand All @@ -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
Expand All @@ -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
}
Expand All @@ -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 (
Expand Down Expand Up @@ -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()
Expand All @@ -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.
Expand Down

0 comments on commit d81def4

Please sign in to comment.