Hi, I need some inputs/thoughts on protobuf-codege...
# plugins
h
Hi, I need some inputs/thoughts on protobuf-codegen for go-grpc.
grpc-gateway
, https://github.com/grpc-ecosystem/grpc-gateway can generate a REST API for grpc services, but it has to be generated in go. This means changing/modifying https://github.com/pantsbuild/pants/blob/main/src/python/pants/backend/codegen/protobuf/go/rules.py
codegen.protobuf.go
. My current approach is, to copy the official source code of codegen.go.protobuf.rules to local
pants_plugin
, and use this custom code generator. For this custom plugin, I am generating a local
go.mod
and
go.sum
which includes
grpc-gateway
packages, and any relevant changes like downloading binaries (https://github.com/pantsbuild/pants/blob/main/src/python/pants/backend/codegen/protobuf/go/rules.py#L596) or adding plugin here https://github.com/pantsbuild/pants/blob/main/src/python/pants/backend/codegen/protobuf/go/rules.py#L500 Do you think it's the right approach ? If yes, then do you think this can/should be added to official code generator(controlled by some variable, like generate_grpc_gateway)? If yes, then once I have my local plugging stabilized, I can create a PR.
g
I'm not very familiar with
grpc-gateway
, but the general approach sounds sensible. I guess this would be a flag (
go_grpc_gateway
?) on the
protobuf_sources
? How does this interop with the regular grpc generation, if at all? I.e. if someone where to set
go_grpc_gateway
and
grpc
both to true, does that create a package with both kinds of services?