fix(build): Prevent duplicated client/server generated code#121
Merged
LucioFranco merged 4 commits intohyperium:masterfrom Nov 9, 2019
Merged
fix(build): Prevent duplicated client/server generated code#121LucioFranco merged 4 commits intohyperium:masterfrom
LucioFranco merged 4 commits intohyperium:masterfrom
Conversation
LucioFranco
approved these changes
Nov 9, 2019
Member
LucioFranco
left a comment
There was a problem hiding this comment.
Thanks for this! I think you may need to rebase against master since we are updating our toolchain to stable.
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.
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).
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.
9b2d659 to
c748fb2
Compare
Contributor
Author
Should be rebased to master that uses the stable toolchain now |
Contributor
Author
|
👍 thanks @LucioFranco! |
|
Nice work! |
rabbitinspace
pushed a commit
to satelit-project/tonic
that referenced
this pull request
Jan 1, 2020
…#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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
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.
This incorrect behaviour is currently observed in tonic-build.
Solution
Reset the
TokenStreams that capture the services for client and server use-cases after the finalization process has written out the generated code.