go-genproto icon indicating copy to clipboard operation
go-genproto copied to clipboard

Please generate these files with google.golang.org/grpc/cmd/protoc-gen-go-grpc

Open EdSchouten opened this issue 2 years ago • 7 comments

It looks like the .pb.go files in this repository are being generated with github.com/golang/protobuf/protoc-gen-go. Though this works, it has the annoying side-effect that all Register*Server() functions depend on concrete type *grpc.Server instead of grpc.ServiceRegistrar. This makes it harder to stub out gRPC server implementations. See: https://github.com/golang/protobuf/issues/1378

Would it be possible to alter this repo to use protoc-gen-go-rpc instead?

EdSchouten avatar Jul 27 '23 19:07 EdSchouten

Hey I am not sure if we are likely to do this anytime soon as this would be a breaking change to everything. Can you please explain the use case for needing to implementing a server -- there may be other patterns you could use I am thinking.

codyoss avatar Jul 31 '23 14:07 codyoss

You need it if you want to register a service against a gRPC server that was created using the xDS package:

https://pkg.go.dev/google.golang.org/grpc/xds#NewGRPCServer

That package offers a custom server type that’s different from *grpc.Server. But it does implement grpc.ServiceRegistrar.

EdSchouten avatar Jul 31 '23 14:07 EdSchouten

As a workaround you can always generate the files yourself if you need. All public protos are located here: https://github.com/googleapis/googleapis

codyoss avatar Jul 31 '23 16:07 codyoss

Yeah, I’m already working around it by letting Bazel apply a patch against the .pb.go files.

EdSchouten avatar Jul 31 '23 16:07 EdSchouten

After some discussion I think will will make the switch sometime in the future, but I don't have a timeline to share. I will leave this issue open for tracking purposes. Thanks for the request

codyoss avatar Jul 31 '23 16:07 codyoss