New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Any interest in implementing tonic::transport::server::Connected
for tokio::net::UnixStream
?
#856
Comments
Yeah, I think this makes sense, I would totally accept a PR for this. |
Awesome. I'll submit a PR for this in the next few days. |
This impl is needed in order to use a tokio UnixStream as the `incoming` argument in methods like `tonic::transport::server::Router::serve_with_incoming_shutdown` Fixes: hyperium#856 Signed-off-by: Anthony Green <agreen@starry.com>
tokio-stream packages a UnixListenerStream that implements futures_core::Stream. Using this cuts down on consumer boilerplate when using UnixStreams with a tonic server. Refs: hyperium#856 Signed-off-by: Anthony Green <agreen@starry.com>
Refs: hyperium#856 Signed-off-by: Anthony Green <agreen@starry.com>
Refs: hyperium#856 Signed-off-by: Anthony Green <agreen@starry.com>
@LucioFranco (or someone else - not really sure who to ask 😁 ) could you check out this PR I put out for the fix and allow me to run workflows? Looks like I need a maintainer to approve running CI |
Yes just took a look, sorry for the delay. Holidays are crazy :D |
@LucioFranco Haha no worries, thanks for taking a look 👍🏽 |
This impl is needed in order to use a tokio UnixStream as the `incoming` argument in methods like `tonic::transport::server::Router::serve_with_incoming_shutdown` Fixes: hyperium#856 Signed-off-by: Anthony Green <agreen@starry.com>
tokio-stream packages a UnixListenerStream that implements futures_core::Stream. Using this cuts down on consumer boilerplate when using UnixStreams with a tonic server. Refs: hyperium#856 Signed-off-by: Anthony Green <agreen@starry.com>
Refs: hyperium#856 Signed-off-by: Anthony Green <agreen@starry.com>
Closing this issue as the the relevant PR has been merged 🎉 |
Feature Request
I started using
tonic
recently and it has been awesome to work with so far! I saw an opportunity for a small contribution that I believe would maketonic
a little easier to use so I wanted to see if there was interest in accepting such a feature - implementingtonic::transport::server::Connected for tokio::net::UnixStream
to allow client code to use aUnixStream
on the server side more easily.Crates
tonic
Motivation
At first glance I thought there was no Unix socket support for tonic clients/servers, but I stumbled upon the
uds
client/server example soon thereafter and I was able to get my server listening on a unix socket easily.That said, I think it would be nice if consumers could use a
tokio::net::UnixStream
on the server side without needing to provide the following (which are currently required):impl tonic::transport::server::Connected for tokio::net::UnixStream
tokio::net::UnixStream
, implementAsyncRead
/AsyncWrite
(only needed since client code can't implement an external trait for an external type)Proposal
I've looked around the repo a bit and I think the main piece of getting this working would be something like this:
To me, the win here is that since tonic itself would be implementing
Connected
, client code would no longer have to define a newtype wrapper aroundUnixStream
and hand-implementConnected
/AsyncRead
/AsyncWrite
on it -tokio-stream
sUnixListenerStream
would then be usable out the box at this point:This could possibly require some other work in
server/mod.rs
but I'm unsure about this part...just wanted to check in on interest level before digging in too far! Thanks for looking!Alternatives
Current solution is to copy the approach from the
uds/server.rs
example, which works right now as-is.The text was updated successfully, but these errors were encountered: