tonic: Client/Server /can be/ duplicated into their include files
Bug Report
Version
master: afa9d9d236b7ca96d70d696ab38aadac7cdf41ff
Platform
Linux RILEY-LT 4.19.43-microsoft-standard #1 SMP Mon May 20 19:35:22 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Crates
cargo-build
Description
When using includes it seems like the client/server are generated into the include file output. This only seems to happen under certain conditions, I believe related to compiling multiple protos at once via tonic_build::configure().compile(&["proto/health.proto", "proto/test.proto"], &["proto"]).unwrap();
Repro here:
https://github.com/rlabrecque/tonic_include_repro
Specifically see: https://github.com/rlabrecque/tonic_include_repro/blob/master/src/proto/google.protobuf.rs
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 18 (7 by maintainers)
Commits related to this issue
- Fix #38 - Use a new prost ServiceGenerator finalizer to fix duplicate client and server definitions — committed to parasyte/tonic by deleted user 5 years ago
- release 0.21.0 (#38) — committed to brentalanmiller/tonic by quininer 4 years ago
There are a few different issues that I’ve found so far. First, take this set of proto files:
Proto files
proto/hello.proto
proto/goodbye.proto
proto/types.proto
And the following
build.rs
:This fails to work because building
goodbye.proto
completely overwrites the output file generated forhello.proto
.Ok, maybe the
Builder
type is smarter, since you can provide a list of paths to multiple proto files? Let’s updatebuild.rs
:And this also fails because now the generated output has duplicate
client
andserver
modules for the two different services defined in thehelloworld
package.I’m curious why it worked fine on tower-grpc as well though. It seems like it’s possible and this is just a regression in the rewrite.
Using tower-grpc with the same build file (gathers all proto files with services in to the array) doesn’t have the same issue
I hit this problem with a different repro case. Compiling two proto files with the same package name defining unique services will output Rust source code like:
Which then leads to errors:
I have to merge all proto files for the single package into one file to workaround this issue.