Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose tonic codegen paths #2104

Open
killzoner opened this issue Dec 17, 2024 · 0 comments
Open

Expose tonic codegen paths #2104

killzoner opened this issue Dec 17, 2024 · 0 comments

Comments

@killzoner
Copy link

killzoner commented Dec 17, 2024

Feature Request

Expose all method paths as constants

Crates

tonic-build

Motivation

I have a use case where I need to send already marshalled proto data on the wire (and so send data without marshalling). I achieved that by partially implementing what the code gen is doing and wrapping some bytes in a type that implements Message trait (basically skipping encoding, directly sending the buffer as is). I fallback to tonic codegen for any route not matched.

That's great, it means tonic is the only implementation (to my knowledge) so far apart from cpp allowing this use case! (See cpp GenericStub and BytesBuffer at https://grpc.io/docs/guides/performance/#c)

But since path match is not fully using codegen, if I ever refacto some proto and the path changes (which is a breaking change to the proto definition but still), it couldn't be caught at all in my code at compile time (this would fallback to tonic codegen with unimplemented method)

Proposal

Expose each route as a constant in the generated package.

It's imposing some convention to be maintained which can be a burden and over complicate codegen

Alternatives

  • There are other ways to achieve binary marshalled data send with current state of tonic
  • No change since it's very specific use case

Side note

  • I'm willing to implement this if deemed useful
  • I'm willing to create an example to demonstrate the use case
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant