Skip to content

Commit

Permalink
cleanup: remove Interface as suffix of (almost all) interface names
Browse files Browse the repository at this point in the history
  • Loading branch information
dfawley committed Jun 4, 2021
1 parent 5c164e2 commit adcfd05
Show file tree
Hide file tree
Showing 30 changed files with 115 additions and 115 deletions.
8 changes: 4 additions & 4 deletions internal/xds/matcher/matcher_header.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ import (
"google.golang.org/grpc/metadata"
)

// HeaderMatcherInterface is an interface for header matchers. These are
// HeaderMatcher is an interface for header matchers. These are
// documented in (EnvoyProxy link here?). These matchers will match on different
// aspects of HTTP header name/value pairs.
type HeaderMatcherInterface interface {
type HeaderMatcher interface {
Match(metadata.MD) bool
String() string
}
Expand Down Expand Up @@ -234,11 +234,11 @@ func (hcm *HeaderContainsMatcher) String() string {

// InvertMatcher inverts the match result of the underlying header matcher.
type InvertMatcher struct {
m HeaderMatcherInterface
m HeaderMatcher
}

// NewInvertMatcher returns a new InvertMatcher.
func NewInvertMatcher(m HeaderMatcherInterface) *InvertMatcher {
func NewInvertMatcher(m HeaderMatcher) *InvertMatcher {
return &InvertMatcher{m: m}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/xds/matcher/matcher_header_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ func TestHeaderSuffixMatcherMatch(t *testing.T) {
func TestInvertMatcherMatch(t *testing.T) {
tests := []struct {
name string
m HeaderMatcherInterface
m HeaderMatcher
md metadata.MD
}{
{
Expand Down
4 changes: 2 additions & 2 deletions internal/xds/rbac/matchers.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,11 @@ func (nm *notMatcher) match(data *RPCData) bool {
// headerMatcher is a matcher that matches on incoming HTTP Headers present
// in the incoming RPC. headerMatcher implements the matcher interface.
type headerMatcher struct {
matcher internalmatcher.HeaderMatcherInterface
matcher internalmatcher.HeaderMatcher
}

func newHeaderMatcher(headerMatcherConfig *v3route_componentspb.HeaderMatcher) (*headerMatcher, error) {
var m internalmatcher.HeaderMatcherInterface
var m internalmatcher.HeaderMatcher
switch headerMatcherConfig.HeaderMatchSpecifier.(type) {
case *v3route_componentspb.HeaderMatcher_ExactMatch:
m = internalmatcher.NewHeaderExactMatcher(headerMatcherConfig.Name, headerMatcherConfig.GetExactMatch())
Expand Down
8 changes: 4 additions & 4 deletions xds/csds/csds.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ import (
_ "google.golang.org/grpc/xds/internal/xdsclient/v3" // Register v3 xds_client.
)

// xdsClientInterface contains methods from xdsClient.Client which are used by
// xdsClient contains methods from xdsClient.Client which are used by
// the server. This is useful for overriding in unit tests.
type xdsClientInterface interface {
type xdsClient interface {
DumpLDS() (string, map[string]xdsclient.UpdateWithMD)
DumpRDS() (string, map[string]xdsclient.UpdateWithMD)
DumpCDS() (string, map[string]xdsclient.UpdateWithMD)
Expand All @@ -58,7 +58,7 @@ type xdsClientInterface interface {

var (
logger = grpclog.Component("xds")
newXDSClient = func() xdsClientInterface {
newXDSClient = func() xdsClient {
c, err := xdsclient.New()
if err != nil {
// If err is not nil, c is a typed nil (of type *xdsclient.Client).
Expand All @@ -76,7 +76,7 @@ var (
type ClientStatusDiscoveryServer struct {
// xdsClient will always be the same in practice. But we keep a copy in each
// server instance for testing.
xdsClient xdsClientInterface
xdsClient xdsClient
}

// NewClientStatusDiscoveryServer returns an implementation of the CSDS server that can be
Expand Down
8 changes: 4 additions & 4 deletions xds/csds/csds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const (
defaultTestTimeout = 10 * time.Second
)

type xdsClientInterfaceWithWatch interface {
type xdsClientWithWatch interface {
WatchListener(string, func(xdsclient.ListenerUpdate, error)) func()
WatchRouteConfig(string, func(xdsclient.RouteConfigUpdate, error)) func()
WatchCluster(string, func(xdsclient.ClusterUpdate, error)) func()
Expand Down Expand Up @@ -250,7 +250,7 @@ func TestCSDS(t *testing.T) {
}
}

func commonSetup(t *testing.T) (xdsClientInterfaceWithWatch, *e2e.ManagementServer, string, v3statuspbgrpc.ClientStatusDiscoveryService_StreamClientStatusClient, func()) {
func commonSetup(t *testing.T) (xdsClientWithWatch, *e2e.ManagementServer, string, v3statuspbgrpc.ClientStatusDiscoveryService_StreamClientStatusClient, func()) {
t.Helper()

// Spin up a xDS management server on a local port.
Expand All @@ -275,7 +275,7 @@ func commonSetup(t *testing.T) (xdsClientInterfaceWithWatch, *e2e.ManagementServ
t.Fatalf("failed to create xds client: %v", err)
}
oldNewXDSClient := newXDSClient
newXDSClient = func() xdsClientInterface { return xdsC }
newXDSClient = func() xdsClient { return xdsC }

// Initialize an gRPC server and register CSDS on it.
server := grpc.NewServer()
Expand Down Expand Up @@ -635,7 +635,7 @@ func protoToJSON(p proto.Message) string {

func TestCSDSNoXDSClient(t *testing.T) {
oldNewXDSClient := newXDSClient
newXDSClient = func() xdsClientInterface { return nil }
newXDSClient = func() xdsClient { return nil }
defer func() { newXDSClient = oldNewXDSClient }()

// Initialize an gRPC server and register CSDS on it.
Expand Down
6 changes: 3 additions & 3 deletions xds/googledirectpath/googlec2p.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ const (
dnsName, xdsName = "dns", "xds"
)

type xdsClientInterface interface {
type xdsClient interface {
Close()
}

// For overriding in unittests.
var (
onGCE = googlecloud.OnGCE

newClientWithConfig = func(config *bootstrap.Config) (xdsClientInterface, error) {
newClientWithConfig = func(config *bootstrap.Config) (xdsClient, error) {
return xdsclient.NewWithConfig(config)
}

Expand Down Expand Up @@ -138,7 +138,7 @@ func (c2pResolverBuilder) Scheme() string {

type c2pResolver struct {
resolver.Resolver
client xdsClientInterface
client xdsClient
}

func (r *c2pResolver) Close() {
Expand Down
2 changes: 1 addition & 1 deletion xds/googledirectpath/googlec2p_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func TestBuildXDS(t *testing.T) {

configCh := make(chan *bootstrap.Config, 1)
oldNewClient := newClientWithConfig
newClientWithConfig = func(config *bootstrap.Config) (xdsClientInterface, error) {
newClientWithConfig = func(config *bootstrap.Config) (xdsClient, error) {
configCh <- config
return tXDSClient, nil
}
Expand Down
8 changes: 4 additions & 4 deletions xds/internal/balancer/cdsbalancer/cdsbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ var (
// not deal with subConns.
return builder.Build(cc, opts), nil
}
newXDSClient func() (xdsClientInterface, error)
newXDSClient func() (xdsClient, error)
buildProvider = buildProviderFunc
)

Expand Down Expand Up @@ -138,9 +138,9 @@ func (cdsBB) ParseConfig(c json.RawMessage) (serviceconfig.LoadBalancingConfig,
return &cfg, nil
}

// xdsClientInterface contains methods from xdsClient.Client which are used by
// xdsClient contains methods from xdsClient.Client which are used by
// the cdsBalancer. This will be faked out in unittests.
type xdsClientInterface interface {
type xdsClient interface {
WatchCluster(string, func(xdsclient.ClusterUpdate, error)) func()
BootstrapConfig() *bootstrap.Config
Close()
Expand Down Expand Up @@ -185,7 +185,7 @@ type cdsBalancer struct {
ccw *ccWrapper // ClientConn interface passed to child LB.
bOpts balancer.BuildOptions // BuildOptions passed to child LB.
updateCh *buffer.Unbounded // Channel for gRPC and xdsClient updates.
xdsClient xdsClientInterface // xDS client to watch Cluster resource.
xdsClient xdsClient // xDS client to watch Cluster resource.
cancelWatch func() // Cluster watch cancel func.
edsLB balancer.Balancer // EDS child policy.
clusterToWatch string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func setupWithXDSCreds(t *testing.T) (*fakeclient.Client, *cdsBalancer, *testEDS

xdsC := fakeclient.NewClient()
oldNewXDSClient := newXDSClient
newXDSClient = func() (xdsClientInterface, error) { return xdsC, nil }
newXDSClient = func() (xdsClient, error) { return xdsC, nil }

builder := balancer.Get(cdsName)
if builder == nil {
Expand Down
2 changes: 1 addition & 1 deletion xds/internal/balancer/cdsbalancer/cdsbalancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func setup(t *testing.T) (*fakeclient.Client, *cdsBalancer, *testEDSBalancer, *x

xdsC := fakeclient.NewClient()
oldNewXDSClient := newXDSClient
newXDSClient = func() (xdsClientInterface, error) { return xdsC, nil }
newXDSClient = func() (xdsClient, error) { return xdsC, nil }

builder := balancer.Get(cdsName)
if builder == nil {
Expand Down
4 changes: 2 additions & 2 deletions xds/internal/balancer/cdsbalancer/cluster_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type clusterHandler struct {
// CDS Balancer cares about is the most recent update.
updateChannel chan clusterHandlerUpdate

xdsClient xdsClientInterface
xdsClient xdsClient
}

func (ch *clusterHandler) updateRootCluster(rootClusterName string) {
Expand Down Expand Up @@ -112,7 +112,7 @@ type clusterNode struct {

// CreateClusterNode creates a cluster node from a given clusterName. This will
// also start the watch for that cluster.
func createClusterNode(clusterName string, xdsClient xdsClientInterface, topLevelHandler *clusterHandler) *clusterNode {
func createClusterNode(clusterName string, xdsClient xdsClient, topLevelHandler *clusterHandler) *clusterNode {
c := &clusterNode{
clusterHandler: topLevelHandler,
}
Expand Down
10 changes: 5 additions & 5 deletions xds/internal/balancer/clusterimpl/balancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func TestDropByCategory(t *testing.T) {
defer xdsclient.ClearCounterForTesting(testClusterName)
xdsC := fakeclient.NewClient()
oldNewXDSClient := newXDSClient
newXDSClient = func() (xdsClientInterface, error) { return xdsC, nil }
newXDSClient = func() (xdsClient, error) { return xdsC, nil }
defer func() { newXDSClient = oldNewXDSClient }()

builder := balancer.Get(Name)
Expand Down Expand Up @@ -233,7 +233,7 @@ func TestDropCircuitBreaking(t *testing.T) {
defer xdsclient.ClearCounterForTesting(testClusterName)
xdsC := fakeclient.NewClient()
oldNewXDSClient := newXDSClient
newXDSClient = func() (xdsClientInterface, error) { return xdsC, nil }
newXDSClient = func() (xdsClient, error) { return xdsC, nil }
defer func() { newXDSClient = oldNewXDSClient }()

builder := balancer.Get(Name)
Expand Down Expand Up @@ -345,7 +345,7 @@ func TestPickerUpdateAfterClose(t *testing.T) {
defer xdsclient.ClearCounterForTesting(testClusterName)
xdsC := fakeclient.NewClient()
oldNewXDSClient := newXDSClient
newXDSClient = func() (xdsClientInterface, error) { return xdsC, nil }
newXDSClient = func() (xdsClient, error) { return xdsC, nil }
defer func() { newXDSClient = oldNewXDSClient }()

builder := balancer.Get(Name)
Expand Down Expand Up @@ -390,7 +390,7 @@ func TestClusterNameInAddressAttributes(t *testing.T) {
defer xdsclient.ClearCounterForTesting(testClusterName)
xdsC := fakeclient.NewClient()
oldNewXDSClient := newXDSClient
newXDSClient = func() (xdsClientInterface, error) { return xdsC, nil }
newXDSClient = func() (xdsClient, error) { return xdsC, nil }
defer func() { newXDSClient = oldNewXDSClient }()

builder := balancer.Get(Name)
Expand Down Expand Up @@ -481,7 +481,7 @@ func TestReResolution(t *testing.T) {
defer xdsclient.ClearCounterForTesting(testClusterName)
xdsC := fakeclient.NewClient()
oldNewXDSClient := newXDSClient
newXDSClient = func() (xdsClientInterface, error) { return xdsC, nil }
newXDSClient = func() (xdsClient, error) { return xdsC, nil }
defer func() { newXDSClient = oldNewXDSClient }()

builder := balancer.Get(Name)
Expand Down
8 changes: 4 additions & 4 deletions xds/internal/balancer/clusterimpl/clusterimpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func init() {
balancer.Register(clusterImplBB{})
}

var newXDSClient func() (xdsClientInterface, error)
var newXDSClient func() (xdsClient, error)

type clusterImplBB struct{}

Expand Down Expand Up @@ -91,9 +91,9 @@ func (clusterImplBB) ParseConfig(c json.RawMessage) (serviceconfig.LoadBalancing
return parseConfig(c)
}

// xdsClientInterface contains only the xds_client methods needed by LRS
// xdsClient contains only the xds_client methods needed by LRS
// balancer. It's defined so we can override xdsclient in tests.
type xdsClientInterface interface {
type xdsClient interface {
ReportLoad(server string) (*load.Store, func())
Close()
}
Expand All @@ -115,7 +115,7 @@ type clusterImplBalancer struct {

bOpts balancer.BuildOptions
logger *grpclog.PrefixLogger
xdsC xdsClientInterface
xdsC xdsClient

config *LBConfig
childLB balancer.Balancer
Expand Down
8 changes: 4 additions & 4 deletions xds/internal/balancer/edsbalancer/eds.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ import (

const edsName = "eds_experimental"

// xdsClientInterface contains only the xds_client methods needed by EDS
// xdsClient contains only the xds_client methods needed by EDS
// balancer. It's defined so we can override xdsclient.New function in tests.
type xdsClientInterface interface {
type xdsClient interface {
WatchEndpoints(clusterName string, edsCb func(xdsclient.EndpointsUpdate, error)) (cancel func())
ReportLoad(server string) (loadStore *load.Store, cancel func())
Close()
Expand All @@ -53,7 +53,7 @@ var (
newEDSBalancer = func(cc balancer.ClientConn, opts balancer.BuildOptions, enqueueState func(priorityType, balancer.State), lw load.PerClusterReporter, logger *grpclog.PrefixLogger) edsBalancerImplInterface {
return newEDSBalancerImpl(cc, opts, enqueueState, lw, logger)
}
newXDSClient func() (xdsClientInterface, error)
newXDSClient func() (xdsClient, error)
)

func init() {
Expand Down Expand Up @@ -145,7 +145,7 @@ type edsBalancer struct {
xdsClientUpdate chan *edsUpdate
childPolicyUpdate *buffer.Unbounded

xdsClient xdsClientInterface
xdsClient xdsClient
loadWrapper *loadstore.Wrapper
config *EDSConfig // may change when passed a different service config
edsImpl edsBalancerImplInterface
Expand Down
2 changes: 1 addition & 1 deletion xds/internal/balancer/edsbalancer/eds_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ func (s) TestEDS_LoadReport(t *testing.T) {
env.CircuitBreakingSupport = true
defer func() { env.CircuitBreakingSupport = origCircuitBreakingSupport }()

// We create an xdsClientWrapper with a dummy xdsClientInterface which only
// We create an xdsClientWrapper with a dummy xdsClient which only
// implements the LoadStore() method to return the underlying load.Store to
// be used.
loadStore := load.NewStore()
Expand Down
2 changes: 1 addition & 1 deletion xds/internal/balancer/edsbalancer/eds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func waitForNewEDSLB(ctx context.Context, ch *testutils.Channel) (*fakeEDSBalanc
func setup(edsLBCh *testutils.Channel) (*fakeclient.Client, func()) {
xdsC := fakeclient.NewClientWithName(testBalancerNameFooBar)
oldNewXDSClient := newXDSClient
newXDSClient = func() (xdsClientInterface, error) { return xdsC, nil }
newXDSClient = func() (xdsClient, error) { return xdsC, nil }

origNewEDSBalancer := newEDSBalancer
newEDSBalancer = func(cc balancer.ClientConn, _ balancer.BuildOptions, _ func(priorityType, balancer.State), _ load.PerClusterReporter, _ *grpclog.PrefixLogger) edsBalancerImplInterface {
Expand Down
2 changes: 1 addition & 1 deletion xds/internal/balancer/edsbalancer/xds_lrs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
func (s) TestXDSLoadReporting(t *testing.T) {
xdsC := fakeclient.NewClient()
oldNewXDSClient := newXDSClient
newXDSClient = func() (xdsClientInterface, error) { return xdsC, nil }
newXDSClient = func() (xdsClient, error) { return xdsC, nil }
defer func() { newXDSClient = oldNewXDSClient }()

builder := balancer.Get(edsName)
Expand Down
10 changes: 5 additions & 5 deletions xds/internal/balancer/lrs/balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func init() {
balancer.Register(&lrsBB{})
}

var newXDSClient func() (xdsClientInterface, error)
var newXDSClient func() (xdsClient, error)

// Name is the name of the LRS balancer.
const Name = "lrs_experimental"
Expand Down Expand Up @@ -169,15 +169,15 @@ func (ccw *ccWrapper) UpdateState(s balancer.State) {
ccw.ClientConn.UpdateState(s)
}

// xdsClientInterface contains only the xds_client methods needed by LRS
// xdsClient contains only the xds_client methods needed by LRS
// balancer. It's defined so we can override xdsclient in tests.
type xdsClientInterface interface {
type xdsClient interface {
ReportLoad(server string) (*load.Store, func())
Close()
}

type xdsClientWrapper struct {
c xdsClientInterface
c xdsClient
cancelLoadReport func()
clusterName string
edsServiceName string
Expand All @@ -187,7 +187,7 @@ type xdsClientWrapper struct {
loadWrapper *loadstore.Wrapper
}

func newXDSClientWrapper(c xdsClientInterface) *xdsClientWrapper {
func newXDSClientWrapper(c xdsClient) *xdsClientWrapper {
return &xdsClientWrapper{
c: c,
loadWrapper: loadstore.NewWrapper(),
Expand Down
2 changes: 1 addition & 1 deletion xds/internal/balancer/lrs/balancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ var (
func TestLoadReporting(t *testing.T) {
xdsC := fakeclient.NewClient()
oldNewXDSClient := newXDSClient
newXDSClient = func() (xdsClientInterface, error) { return xdsC, nil }
newXDSClient = func() (xdsClient, error) { return xdsC, nil }
defer func() { newXDSClient = oldNewXDSClient }()

builder := balancer.Get(Name)
Expand Down
Loading

0 comments on commit adcfd05

Please sign in to comment.