hyperium / tonic

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

Current "uds" example does not compile #1732

Closed Ruddickmg closed 3 months ago

Ruddickmg commented 3 months ago

Bug Report

The current "uds" example does not compile

Version

All my dependencies

[dependencies]
base64 = "0.22.1"
tonic = "0.11.0"
bytes = "1.6.0"
prost-derive = "0.12.6"
prost = "0.12.6"
tokio = { version = "1.38.0", features = ["macros", "rt-multi-thread"] }
hyper-util = {  version = "0.1.5", features = ["tokio"] }
tower = "0.4.13"
vaultrs = "0.7.1"
tokio-stream = { version = "0.1.15", features = ["net"]}

[build-dependencies]
tonic-build = "0.11.0"

Platform

64-bit Ubuntu 22.04.4 LTS

Description

When copy pasting the example found here the code does not compile, resulting in the following error:

error[E0277]: the trait bound `tokio::net::UnixStream: hyper::rt::io::Read` is not satisfied
  --> src/utilities/socket.rs:23:6
   |
23 |     .connect_with_connector(service_fn(|_| async {
   |      ^^^^^^^^^^^^^^^^^^^^^^ the trait `hyper::rt::io::Read` is not implemented for `tokio::net::UnixStream`, which is required by `ServiceFn<{closure@src/utilities/socket.rs:23:40: 23:43}>: MakeConnection<Uri>`
   |
   = help: the following other types implement trait `hyper::rt::io::Read`:
             TokioIo<T>
             Box<T>
             hyper::upgrade::Upgraded
             Pin<P>
             &mut T
   = note: required for `TokioIo<tokio::net::UnixStream>` to implement `AsyncRead`
   = note: required for `ServiceFn<{closure@src/utilities/socket.rs:23:40: 23:43}>` to implement `MakeConnection<Uri>`
ikrivosheev commented 3 months ago

@Ruddickmg hello! tonic = "0.11" doesn't support hyper = "1". Can you check current master branch? Well, we are waiting for 0.12 release.

Issue: https://github.com/hyperium/tonic/issues/1734

str4d commented 3 months ago

The example code link above is from recent master branch, after the hyper 1 migration. That it doesn't work with tokio 0.11 is intentional: the current state of the master branch reflects the current development state.

You should instead look at the "uds" example state as of the 0.11.0 tag, which should work with tokio 0.11: https://github.com/hyperium/tonic/blob/v0.11.0/examples/src/uds/client.rs

ikrivosheev commented 3 months ago

I think, we can close the issue.