From 08b0eb63148fc03359c4eb6aeaa95ab9eac4008f Mon Sep 17 00:00:00 2001 From: Allan Zhang Date: Wed, 6 Dec 2023 23:52:39 -0500 Subject: [PATCH] Chop out AddrStream Replaced with `tokio::net::TcpStream`. Inspired by https://github.com/hyperium/hyper/issues/2850 --- tonic/src/transport/server/conn.rs | 12 ------------ tonic/src/transport/server/incoming.rs | 9 +++------ 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/tonic/src/transport/server/conn.rs b/tonic/src/transport/server/conn.rs index 907cf4965..37bcc561b 100644 --- a/tonic/src/transport/server/conn.rs +++ b/tonic/src/transport/server/conn.rs @@ -1,4 +1,3 @@ -use hyper::server::conn::AddrStream; use std::net::SocketAddr; use tokio::net::TcpStream; @@ -86,17 +85,6 @@ impl TcpConnectInfo { } } -impl Connected for AddrStream { - type ConnectInfo = TcpConnectInfo; - - fn connect_info(&self) -> Self::ConnectInfo { - TcpConnectInfo { - local_addr: Some(self.local_addr()), - remote_addr: Some(self.remote_addr()), - } - } -} - impl Connected for TcpStream { type ConnectInfo = TcpConnectInfo; diff --git a/tonic/src/transport/server/incoming.rs b/tonic/src/transport/server/incoming.rs index bc1bb7650..0ebbd85c8 100644 --- a/tonic/src/transport/server/incoming.rs +++ b/tonic/src/transport/server/incoming.rs @@ -1,9 +1,5 @@ use super::{Connected, Server}; use crate::transport::service::ServerIo; -use hyper::server::{ - accept::Accept, - conn::{AddrIncoming, AddrStream}, -}; use std::{ net::SocketAddr, pin::{pin, Pin}, @@ -12,7 +8,7 @@ use std::{ }; use tokio::{ io::{AsyncRead, AsyncWrite}, - net::TcpListener, + net::{TcpListener, TcpStream}, }; use tokio_stream::{Stream, StreamExt}; @@ -187,7 +183,7 @@ impl TcpIncoming { } impl Stream for TcpIncoming { - type Item = Result; + type Item = Result; fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { Pin::new(&mut self.inner).poll_accept(cx) @@ -207,3 +203,4 @@ mod tests { let _t3 = TcpIncoming::new(addr, true, None).unwrap(); } } +