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

Using tonic for clients still pulls in extra dependencies #1014

Open djc opened 2 years ago

djc commented 2 years ago

From my comment in https://github.com/hyperium/tonic/issues/959#issuecomment-1108264503:

I finally tried using #960 and I don't think it's an adequate fix. First of all, the tls feature still pulls in transport, so by default if you pull in tls or one of the features that depend on it, you'll still get the server-side dependencies. That part can actually be worked around by depending on the other required features directly, but then I noticed that the entire tonic::transport module is unavailable if the transport feature is disabled, so I don't have access to things like Error, Channel or Endpoint from that module.

Should I submit a PR replacing the use of transport internally with channel for client-side or both-side items?

LucioFranco commented 2 years ago

Ugh yeah seems like a mess, honestly, I would just use tonic without the transport module. Its still a bit of a mess but will allow you better fine grained control over what you pull in. Is this change for something internal or is it in a public repo?

djc commented 2 years ago

Something internal, though it's probably also relevant for parts of opentelemetry-rust (notably, opentelemetry-stackdriver).

LucioFranco commented 2 years ago

Do you think migrating to using hyper is feasible?

LucioFranco commented 2 years ago

I wrote this PR that should make using hyper directly much easier https://github.com/hyperium/tonic/pull/1017

djc commented 2 years ago

Is there any example code for using tonic without the transport stuff?

LucioFranco commented 2 years ago

@djc the rustls examples under the tls folder has examples of using hyper. In general, it should just work, except servers don't provide the make service portion.