tonic icon indicating copy to clipboard operation
tonic copied to clipboard

Using tonic for clients still pulls in extra dependencies

Open djc opened this issue 2 years ago • 6 comments

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?

djc avatar Jun 13 '22 08:06 djc

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?

LucioFranco avatar Jun 15 '22 15:06 LucioFranco

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

djc avatar Jun 15 '22 15:06 djc

Do you think migrating to using hyper is feasible?

LucioFranco avatar Jun 15 '22 15:06 LucioFranco

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

LucioFranco avatar Jun 15 '22 16:06 LucioFranco

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

djc avatar Jun 30 '22 09:06 djc

@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.

LucioFranco avatar Jun 30 '22 14:06 LucioFranco