prost icon indicating copy to clipboard operation
prost copied to clipboard

Make it possible to only generate the services

Open Guiguiprim opened this issue 4 years ago • 4 comments

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 no service_generator)
  • crate Business-A depends on Messages
  • crate Services depends on Messages (use tonic-build with service_only(true))
  • crate Binary depends on Services and Business-A

Guiguiprim avatar Oct 14 '21 15:10 Guiguiprim

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.

danburkert avatar Nov 09 '21 06:11 danburkert

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.

tonic-prost-test.tar.gz

But you are right I could split my proto file: echo.messages.proto and echo.services.proto, but I would prefer to avoid this.

Guiguiprim avatar Nov 09 '21 09:11 Guiguiprim

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.

Guiguiprim avatar Apr 16 '24 09:04 Guiguiprim