Duplicated code generated for GRPC client/server
Hi All, I'm running the vtproto generator on the proto below, we use both the go + go-grpc generators in addition to vtproto.
However when I run the vtproto generator it duplicates the grpc generated code.
What's the best way to deal with this type of proto to remove the duplicated code?
- Split the proto files into two files: messages.proto + grpc.proto?
- Ignore the generated gRPC types when running the vtproto generator?
Thanks! Glenn
Single proto
Attached are the generated files: gen.zip
syntax = "proto3";
package pingpong;
option go_package = "pingpong";
service PingPongService {
rpc Pong(PingRequest) returns (PongResponse) {}
}
message PingRequest {
string hello = 1;
}
message PongResponse {
string world = 1;
}
Split protos
Attached are the split generated files: gen 2.zip
messages.proto
syntax = "proto3";
package pingpong;
option go_package = "gen";
message PingRequest {
string hello = 1;
}
message PongResponse {
string world = 1;
}
grpc.proto
syntax = "proto3";
package pingpong;
option go_package = "gen";
import "messages.proto";
service PingPongService {
rpc Pong(PingRequest) returns (PongResponse) {}
}
There seems to be an unfinished and undocumented feature that gets pulled in by default, conflicting with protoc-gen-go-grpc. Should this be excluded from the default feature list?
- https://github.com/planetscale/vtprotobuf/tree/main/features/grpc
To answer the original question, the plugin defaults to all generation "features", which I believe is something like:
features=pool+size+equal+clone+unmarshal+unmarshal_unsafe+grpc+marshal+marshal_strict
To fix the issue, explicitly set the necessary plugin options and omit the "grpc" plugin option to avoid duplication.