hyperium / tonic

A native gRPC client & server implementation with async/await support.
https://docs.rs/tonic
MIT License
10.02k stars 1.02k forks source link

Remove `protoc-reflection` dependency on `protoc` bin #1148

Closed julienfouilhe closed 5 months ago

julienfouilhe commented 2 years ago

Feature Request

Crates

Motivation

I tried to add reflection to my gRPC server using tonic-reflection. I do not use tonic-build, but rather precompile proto files with protoc plugins, separately.

But tonic-reflection uses include_proto which seems to be using protoc under the hood.

This means that in order to use this package there needs to be protoc installed. It's a problem for CI/CD pipelines, building a docker image, etc... All these now need to first install the protoc dependency.

Proposal

Since include_proto is used for a single static file, it seems to me that it would be great to "pre compile" it instead?

Alternatives

hexfusion commented 2 years ago

Completely agree that protoc should be an optional dependency for tonic in general. For example grpc-go does not rely directly on protoc. If it is needed for testing etc it feels these can be gated by feature flags. I have never contributed to the repo but if we are open to the change I would be interested in trying to help.

LucioFranco commented 2 years ago

If by pre compile you commit the generated code and make it so end users of the library don't need to have a protoc in their path. Then yes we can make that change in line with how tonic-health does it. You can follow this PR https://github.com/hyperium/tonic/pull/1065 as an example. TL;DR: We create a test that does the build generation that will check that the proto code is up to date with what is committed so when we publish you don't need to build anything. I believe this should solve your problem.

tottoto commented 5 months ago

Resolved in #1151.