Skip to content

Commit 4a199db

Browse files
authored
xds: split proto imports for message and service (#2812)
1 parent ab90977 commit 4a199db

File tree

6 files changed

+19
-15
lines changed

6 files changed

+19
-15
lines changed

balancer/xds/lrs/lrs.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17+
// Package lrs implements load reporting service for xds balancer.
1718
package lrs
1819

1920
import (
@@ -28,6 +29,7 @@ import (
2829
"google.golang.org/grpc/balancer/xds/internal"
2930
basepb "google.golang.org/grpc/balancer/xds/internal/proto/envoy/api/v2/core/base"
3031
loadreportpb "google.golang.org/grpc/balancer/xds/internal/proto/envoy/api/v2/endpoint/load_report"
32+
lrsgrpc "google.golang.org/grpc/balancer/xds/internal/proto/envoy/service/load_stats/v2/lrs"
3133
lrspb "google.golang.org/grpc/balancer/xds/internal/proto/envoy/service/load_stats/v2/lrs"
3234
"google.golang.org/grpc/grpclog"
3335
"google.golang.org/grpc/internal/backoff"
@@ -126,7 +128,7 @@ func (ls *lrsStore) buildStats() []*loadreportpb.ClusterStats {
126128
//
127129
// It retries the call (with backoff) until ctx is canceled.
128130
func (ls *lrsStore) ReportTo(ctx context.Context, cc *grpc.ClientConn) {
129-
c := lrspb.NewLoadReportingServiceClient(cc)
131+
c := lrsgrpc.NewLoadReportingServiceClient(cc)
130132
var (
131133
retryCount int
132134
doBackoff bool
@@ -188,7 +190,7 @@ func (ls *lrsStore) ReportTo(ctx context.Context, cc *grpc.ClientConn) {
188190
}
189191
}
190192

191-
func (ls *lrsStore) sendLoads(ctx context.Context, stream lrspb.LoadReportingService_StreamLoadStatsClient, clusterName string, interval time.Duration) {
193+
func (ls *lrsStore) sendLoads(ctx context.Context, stream lrsgrpc.LoadReportingService_StreamLoadStatsClient, clusterName string, interval time.Duration) {
192194
tick := time.NewTicker(interval)
193195
defer tick.Stop()
194196
for {

balancer/xds/lrs/lrs_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535
"google.golang.org/grpc/balancer/xds/internal"
3636
basepb "google.golang.org/grpc/balancer/xds/internal/proto/envoy/api/v2/core/base"
3737
loadreportpb "google.golang.org/grpc/balancer/xds/internal/proto/envoy/api/v2/endpoint/load_report"
38+
lrsgrpc "google.golang.org/grpc/balancer/xds/internal/proto/envoy/service/load_stats/v2/lrs"
3839
lrspb "google.golang.org/grpc/balancer/xds/internal/proto/envoy/service/load_stats/v2/lrs"
3940
"google.golang.org/grpc/codes"
4041
"google.golang.org/grpc/status"
@@ -136,7 +137,7 @@ type lrsServer struct {
136137
reportingInterval *durationpb.Duration
137138
}
138139

139-
func (lrss *lrsServer) StreamLoadStats(stream lrspb.LoadReportingService_StreamLoadStatsServer) error {
140+
func (lrss *lrsServer) StreamLoadStats(stream lrsgrpc.LoadReportingService_StreamLoadStatsServer) error {
140141
req, err := stream.Recv()
141142
if err != nil {
142143
return err
@@ -189,7 +190,7 @@ func setupServer(t *testing.T, reportingInterval *durationpb.Duration) (addr str
189190
drops: make(map[string]uint64),
190191
reportingInterval: reportingInterval,
191192
}
192-
lrspb.RegisterLoadReportingServiceServer(svr, lrss)
193+
lrsgrpc.RegisterLoadReportingServiceServer(svr, lrss)
193194
go svr.Serve(lis)
194195
return lis.Addr().String(), lrss, func() {
195196
svr.Stop()

balancer/xds/xds_client.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import (
3535
basepb "google.golang.org/grpc/balancer/xds/internal/proto/envoy/api/v2/core/base"
3636
discoverypb "google.golang.org/grpc/balancer/xds/internal/proto/envoy/api/v2/discovery"
3737
edspb "google.golang.org/grpc/balancer/xds/internal/proto/envoy/api/v2/eds"
38-
adspb "google.golang.org/grpc/balancer/xds/internal/proto/envoy/service/discovery/v2/ads"
38+
adsgrpc "google.golang.org/grpc/balancer/xds/internal/proto/envoy/service/discovery/v2/ads"
3939
"google.golang.org/grpc/balancer/xds/lrs"
4040
"google.golang.org/grpc/grpclog"
4141
"google.golang.org/grpc/internal/backoff"
@@ -60,7 +60,7 @@ var (
6060
type client struct {
6161
ctx context.Context
6262
cancel context.CancelFunc
63-
cli adspb.AggregatedDiscoveryServiceClient
63+
cli adsgrpc.AggregatedDiscoveryServiceClient
6464
opts balancer.BuildOptions
6565
balancerName string // the traffic director name
6666
serviceName string // the user dial target name
@@ -164,7 +164,7 @@ func (c *client) newEDSRequest() *discoverypb.DiscoveryRequest {
164164
}
165165

166166
func (c *client) makeADSCall() {
167-
c.cli = adspb.NewAggregatedDiscoveryServiceClient(c.cc)
167+
c.cli = adsgrpc.NewAggregatedDiscoveryServiceClient(c.cc)
168168
retryCount := 0
169169
var doRetry bool
170170

balancer/xds/xds_client_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ import (
4242
discoverypb "google.golang.org/grpc/balancer/xds/internal/proto/envoy/api/v2/discovery"
4343
edspb "google.golang.org/grpc/balancer/xds/internal/proto/envoy/api/v2/eds"
4444
endpointpb "google.golang.org/grpc/balancer/xds/internal/proto/envoy/api/v2/endpoint/endpoint"
45-
adspb "google.golang.org/grpc/balancer/xds/internal/proto/envoy/service/discovery/v2/ads"
46-
lrspb "google.golang.org/grpc/balancer/xds/internal/proto/envoy/service/load_stats/v2/lrs"
45+
adsgrpc "google.golang.org/grpc/balancer/xds/internal/proto/envoy/service/discovery/v2/ads"
46+
lrsgrpc "google.golang.org/grpc/balancer/xds/internal/proto/envoy/service/load_stats/v2/lrs"
4747
"google.golang.org/grpc/codes"
4848
"google.golang.org/grpc/resolver"
4949
"google.golang.org/grpc/status"
@@ -205,7 +205,7 @@ type response struct {
205205
err error
206206
}
207207

208-
func (ttd *testTrafficDirector) StreamAggregatedResources(s adspb.AggregatedDiscoveryService_StreamAggregatedResourcesServer) error {
208+
func (ttd *testTrafficDirector) StreamAggregatedResources(s adsgrpc.AggregatedDiscoveryService_StreamAggregatedResourcesServer) error {
209209
for {
210210
req, err := s.Recv()
211211
if err != nil {
@@ -242,7 +242,7 @@ func (ttd *testTrafficDirector) StreamAggregatedResources(s adspb.AggregatedDisc
242242
}
243243
}
244244

245-
func (ttd *testTrafficDirector) DeltaAggregatedResources(adspb.AggregatedDiscoveryService_DeltaAggregatedResourcesServer) error {
245+
func (ttd *testTrafficDirector) DeltaAggregatedResources(adsgrpc.AggregatedDiscoveryService_DeltaAggregatedResourcesServer) error {
246246
return status.Error(codes.Unimplemented, "")
247247
}
248248

@@ -284,8 +284,8 @@ func setupServer(t *testing.T) (addr string, td *testTrafficDirector, lrss *lrsS
284284
Nanos: 0,
285285
},
286286
}
287-
adspb.RegisterAggregatedDiscoveryServiceServer(svr, td)
288-
lrspb.RegisterLoadReportingServiceServer(svr, lrss)
287+
adsgrpc.RegisterAggregatedDiscoveryServiceServer(svr, td)
288+
lrsgrpc.RegisterLoadReportingServiceServer(svr, lrss)
289289
go svr.Serve(lis)
290290
return lis.Addr().String(), td, lrss, func() {
291291
svr.Stop()

balancer/xds/xds_lrs_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333
"google.golang.org/grpc/balancer"
3434
"google.golang.org/grpc/balancer/xds/internal"
3535
basepb "google.golang.org/grpc/balancer/xds/internal/proto/envoy/api/v2/core/base"
36+
lrsgrpc "google.golang.org/grpc/balancer/xds/internal/proto/envoy/service/load_stats/v2/lrs"
3637
lrspb "google.golang.org/grpc/balancer/xds/internal/proto/envoy/service/load_stats/v2/lrs"
3738
"google.golang.org/grpc/codes"
3839
"google.golang.org/grpc/resolver"
@@ -46,7 +47,7 @@ type lrsServer struct {
4647
reportingInterval *durationpb.Duration
4748
}
4849

49-
func (lrss *lrsServer) StreamLoadStats(stream lrspb.LoadReportingService_StreamLoadStatsServer) error {
50+
func (lrss *lrsServer) StreamLoadStats(stream lrsgrpc.LoadReportingService_StreamLoadStatsServer) error {
5051
req, err := stream.Recv()
5152
if err != nil {
5253
return err

benchmark/primitives/syncmap_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
package primitives
18+
package primitives_test
1919

2020
import (
2121
"sync"

0 commit comments

Comments
 (0)