fix(transport): remove needless BoxFuture (#644)
Should save some allocation. Didn't actually benchmark it.
This commit is contained in:
@@ -23,10 +23,7 @@ pub(crate) use tokio_rustls::server::TlsStream;
|
|||||||
use crate::transport::Error;
|
use crate::transport::Error;
|
||||||
|
|
||||||
use self::recover_error::RecoverError;
|
use self::recover_error::RecoverError;
|
||||||
use super::{
|
use super::service::{GrpcTimeout, Or, Routes, ServerIo};
|
||||||
service::{GrpcTimeout, Or, Routes, ServerIo},
|
|
||||||
BoxFuture,
|
|
||||||
};
|
|
||||||
use crate::{body::BoxBody, request::ConnectionInfo};
|
use crate::{body::BoxBody, request::ConnectionInfo};
|
||||||
use futures_core::Stream;
|
use futures_core::Stream;
|
||||||
use futures_util::{
|
use futures_util::{
|
||||||
@@ -643,7 +640,7 @@ where
|
|||||||
{
|
{
|
||||||
type Response = BoxService;
|
type Response = BoxService;
|
||||||
type Error = crate::Error;
|
type Error = crate::Error;
|
||||||
type Future = BoxFuture<Self::Response, Self::Error>;
|
type Future = future::Ready<Result<Self::Response, Self::Error>>;
|
||||||
|
|
||||||
fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||||
Ok(()).into()
|
Ok(()).into()
|
||||||
@@ -660,21 +657,19 @@ where
|
|||||||
let timeout = self.timeout;
|
let timeout = self.timeout;
|
||||||
let trace_interceptor = self.trace_interceptor.clone();
|
let trace_interceptor = self.trace_interceptor.clone();
|
||||||
|
|
||||||
Box::pin(async move {
|
let svc = ServiceBuilder::new()
|
||||||
let svc = ServiceBuilder::new()
|
.layer_fn(RecoverError::new)
|
||||||
.layer_fn(RecoverError::new)
|
.option_layer(concurrency_limit.map(ConcurrencyLimitLayer::new))
|
||||||
.option_layer(concurrency_limit.map(ConcurrencyLimitLayer::new))
|
.layer_fn(|s| GrpcTimeout::new(s, timeout))
|
||||||
.layer_fn(|s| GrpcTimeout::new(s, timeout))
|
.service(svc);
|
||||||
.service(svc);
|
|
||||||
|
|
||||||
let svc = BoxService::new(Svc {
|
let svc = BoxService::new(Svc {
|
||||||
inner: svc,
|
inner: svc,
|
||||||
trace_interceptor,
|
trace_interceptor,
|
||||||
conn_info,
|
conn_info,
|
||||||
});
|
});
|
||||||
|
|
||||||
Ok(svc)
|
future::ready(Ok(svc))
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user