prost
prost copied to clipboard
Make it possible to only generate the services
This make it possible to generate only the messages in one crate (with dependencies only on prost) and the services in another crate (with dependencies on the messages crate and some networking crate like tonic). This offers more possibilities in workspace organization (separation of concerns and better build parallelization).
For example:
- crate
Messages(use prost-build with noservice_generator) - crate
Business-Adepends onMessages - crate
Servicesdepends onMessages(use tonic-build withservice_only(true)) - crate
Binarydepends onServicesandBusiness-A
Can you not get the same behavior by registering an extern_path mapping all of the symbols to the remote crate? Practically speaking I think you'd need to do that to get the types to line up.
extern_path only makes it possible for imported files to be generated in an other crate.
Here I want the content of one proto file to be split in two crates. The messages in one crate and the services in an other.
(In order for it to work I do need to re-export the messages in the services crate [so that the services implementation find the messages, using super::).
As an attached file, a proof-of-concept, I should have added it sooner.
But you are right I could split my proto file: echo.messages.proto and echo.services.proto, but I would prefer to avoid this.
Hello, Coming back on this.
For dependencies tree and build performance, I want to split in two crates the types and the clients declared in some protobuf that I can not split. Even more, I actually need to because one of my crates is used in some python binding and it can not bring tonic as a dependency but needs to bring some proto types.
This new API make it possible to have one crate with only the types definitions, then a second crate depending one the first one with only the tonic client (and doing so without altering the protobuf definitions).
Thank you for your consideration.