Skip to content
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

fix(transport): remove needless BoxFuture #644

Merged
merged 1 commit into from
May 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 13 additions & 18 deletions tonic/src/transport/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ pub(crate) use tokio_rustls::server::TlsStream;
use crate::transport::Error;

use self::recover_error::RecoverError;
use super::{
service::{GrpcTimeout, Or, Routes, ServerIo},
BoxFuture,
};
use super::service::{GrpcTimeout, Or, Routes, ServerIo};
use crate::{body::BoxBody, request::ConnectionInfo};
use futures_core::Stream;
use futures_util::{
Expand Down Expand Up @@ -643,7 +640,7 @@ where
{
type Response = BoxService;
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>> {
Ok(()).into()
Expand All @@ -660,21 +657,19 @@ where
let timeout = self.timeout;
let trace_interceptor = self.trace_interceptor.clone();

Box::pin(async move {
let svc = ServiceBuilder::new()
.layer_fn(RecoverError::new)
.option_layer(concurrency_limit.map(ConcurrencyLimitLayer::new))
.layer_fn(|s| GrpcTimeout::new(s, timeout))
.service(svc);
let svc = ServiceBuilder::new()
.layer_fn(RecoverError::new)
.option_layer(concurrency_limit.map(ConcurrencyLimitLayer::new))
.layer_fn(|s| GrpcTimeout::new(s, timeout))
.service(svc);

let svc = BoxService::new(Svc {
inner: svc,
trace_interceptor,
conn_info,
});
let svc = BoxService::new(Svc {
inner: svc,
trace_interceptor,
conn_info,
});

Ok(svc)
})
future::ready(Ok(svc))
}
}

Expand Down