fix(build): Prevent duplicated client/server generated code (#121)
* fix(build): Prevent duplicated client/server generated code The tonic-build process collects up RPC services as they are provided by prost, before writing them out as part of the finalization step for a given protocol buffer package. In the case of imported protocol buffer packages, there may be RPC services included by import in addition to those in the top-level package. Therefore it is necessary to make sure each set of client/server services gathered by tonic-build is cleared after the finalization process for a given protocol buffer package, otherwise they will be incorrectly aggregated as the generation process proceeds through the subsequent packages. * Test case for duplicated client/server generated code A simple test case that will fail to build without a fix to prevent RPC services being duplicated into inappropriate modules (that related to particular protocol buffer packages). * Additional test case for included_service Introduces an additional case that captures making sure services defined before including a package with additional services doesn't incidentially clear such precursor services from the including package. * Fix unnecessary newline to keep `cargo fmt` happy
This commit is contained in:
committed by
Lucio Franco
parent
4d4dbdf074
commit
b02b4b238b
@@ -0,0 +1,11 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package includee;
|
||||
|
||||
service Included {
|
||||
rpc SomeMethod(SomeRequest) returns (SomeResponse) {}
|
||||
}
|
||||
|
||||
message SomeRequest {}
|
||||
|
||||
message SomeResponse {}
|
||||
@@ -0,0 +1,11 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package includer;
|
||||
|
||||
message TopMessage {}
|
||||
|
||||
service TopService {
|
||||
rpc TopMethod(TopMessage) returns (TopMessage) {}
|
||||
}
|
||||
|
||||
import "includee.proto";
|
||||
Reference in New Issue
Block a user