Skip to content

Commit

Permalink
cmd/protoc-gen-go-grpc: rework service registration (#3828)
Browse files Browse the repository at this point in the history
  • Loading branch information
dfawley authored Aug 25, 2020
1 parent 410880d commit 44d73df
Show file tree
Hide file tree
Showing 76 changed files with 3,994 additions and 2,019 deletions.
2 changes: 1 addition & 1 deletion Documentation/server-reflection-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ make the following changes:
@@ -61,6 +62,8 @@ func main() {
}
s := grpc.NewServer()
pb.RegisterGreeterServer(s, &server{})
pb.RegisterGreeterService(s, &pb.GreeterService{SayHello: sayHello})
+ // Register reflection service on gRPC server.
+ reflection.Register(s)
if err := s.Serve(lis); err != nil {
Expand Down
118 changes: 118 additions & 0 deletions balancer/grpclb/grpc_lb_v1/load_balancer.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

147 changes: 49 additions & 98 deletions balancer/grpclb/grpc_lb_v1/load_balancer_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions balancer/grpclb/grpclb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,6 @@ func (b *remoteBalancer) BalanceLoad(stream lbgrpc.LoadBalancer_BalanceLoadServe
}

type testServer struct {
testpb.UnimplementedTestServiceServer

addr string
fallback bool
}
Expand Down Expand Up @@ -306,7 +304,11 @@ func startBackends(sn string, fallback bool, lis ...net.Listener) (servers []*gr
sn: sn,
}
s := grpc.NewServer(grpc.Creds(creds))
testpb.RegisterTestServiceServer(s, &testServer{addr: l.Addr().String(), fallback: fallback})
ts := &testServer{addr: l.Addr().String(), fallback: fallback}
testpb.RegisterTestServiceService(s, &testpb.TestServiceService{
EmptyCall: ts.EmptyCall,
FullDuplexCall: ts.FullDuplexCall,
})
servers = append(servers, s)
go func(s *grpc.Server, l net.Listener) {
s.Serve(l)
Expand Down
Loading

0 comments on commit 44d73df

Please sign in to comment.