Skip to content

Commit

Permalink
Chop out AddrStream
Browse files Browse the repository at this point in the history
Replaced with `tokio::net::TcpStream`.
Inspired by hyperium/hyper#2850
  • Loading branch information
allan2 authored and alexrudy committed May 20, 2024
1 parent e96385c commit 9f58136
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 18 deletions.
12 changes: 0 additions & 12 deletions tonic/src/transport/server/conn.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use hyper::server::conn::AddrStream;
use std::net::SocketAddr;
use tokio::net::TcpStream;

Expand Down Expand Up @@ -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;

Expand Down
9 changes: 3 additions & 6 deletions tonic/src/transport/server/incoming.rs
Original file line number Diff line number Diff line change
@@ -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},
Expand All @@ -12,7 +8,7 @@ use std::{
};
use tokio::{
io::{AsyncRead, AsyncWrite},
net::TcpListener,
net::{TcpListener, TcpStream},
};
use tokio_stream::{Stream, StreamExt};

Expand Down Expand Up @@ -187,7 +183,7 @@ impl TcpIncoming {
}

impl Stream for TcpIncoming {
type Item = Result<AddrStream, std::io::Error>;
type Item = Result<TcpStream, std::io::Error>;

fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
Pin::new(&mut self.inner).poll_accept(cx)
Expand All @@ -207,3 +203,4 @@ mod tests {
let _t3 = TcpIncoming::new(addr, true, None).unwrap();
}
}

0 comments on commit 9f58136

Please sign in to comment.