You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// We will ignore this uri because uds do not use it
// if your connector does use the uri it will be provided
// as the request to the `MakeConnection`.
let channel = Endpoint::try_from("http://[::]:50051")?
.connect_with_connector(service_fn(|_:Uri| {
let path = "/tmp/tonic/helloworld";
// Connect to a Uds socket
UnixStream::connect(path)
}))
.await?;
letmut client = GreeterClient::new(channel);
It would be great if tonic and its hyperium dependencies, as needed, took ownership of the specified path to avoid the user needing to vend a &'static str.
Update unix domain socket examples to show configurable paths. It
demonstrates a way of configuring the UDS client using the ustr crate to
meet the closure capture requirements of the connector service_fn.
Fixes: hyperium#1611
Refs: hyperium#1612
I second this and am currently using Box::leak() to work around it. Some of my rust teammates helped me out: An Arc or a cloned PathBuf should also meet the 'static requirements.
like
let path = PathBuf::from("/tmp/tonic/helloworld");let channel = Endpoint::try_from("http://[::]:50051")?
.connect_with_connector(service_fn(move |_:Uri| {// Connect to a Uds socketUnixStream::connect(path.clone())})).await?;
Feature Request
Support non-static UDS client connection paths
Motivation
Currently the UDS client example is using a static path, I believe because of the ownership requirements of the service function closure:
tonic/examples/src/uds/client.rs
Lines 16 to 28 in c30cb78
It would be great if
tonic
and itshyperium
dependencies, as needed, took ownership of the specified path to avoid the user needing to vend a&'static str
.Related
The text was updated successfully, but these errors were encountered: