From e575a8c18c87fa5fa690c38256cdf230a4ab482c Mon Sep 17 00:00:00 2001 From: Hossein Mayboudi Date: Wed, 27 Jan 2021 18:50:56 +0330 Subject: [PATCH 1/2] fix(examples): Fix tower examples based on [tower issue 547] (https://github.com/tower-rs/tower/issues/547), "The original service is ready, but the clone is not necessarily ready." Issue Number: #545 --- examples/src/tower/client.rs | 11 ++++------- examples/src/tower/server.rs | 9 +++------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/examples/src/tower/client.rs b/examples/src/tower/client.rs index 89da0670b..1496daa76 100644 --- a/examples/src/tower/client.rs +++ b/examples/src/tower/client.rs @@ -1,5 +1,6 @@ -use hello_world::greeter_client::GreeterClient; +use futures::TryFutureExt; use hello_world::HelloRequest; +use hello_world::greeter_client::GreeterClient; use service::AuthSvc; use tonic::transport::Channel; @@ -57,13 +58,9 @@ mod service { } fn call(&mut self, req: Request) -> Self::Future { - let mut channel = self.inner.clone(); - - Box::pin(async move { - // Do extra async work here... + // Do extra async work here... - channel.call(req).await.map_err(Into::into) - }) + Box::pin(self.inner.call(req).err_into::()) } } } diff --git a/examples/src/tower/server.rs b/examples/src/tower/server.rs index d25097049..853fdd614 100644 --- a/examples/src/tower/server.rs +++ b/examples/src/tower/server.rs @@ -1,3 +1,4 @@ +use futures::TryFutureExt; use hyper::{Body, Request as HyperRequest, Response as HyperResponse}; use std::task::{Context, Poll}; use tonic::{ @@ -71,13 +72,9 @@ where } fn call(&mut self, req: HyperRequest) -> Self::Future { - let mut svc = self.inner.clone(); + // Do async work here.... - Box::pin(async move { - // Do async work here.... - - svc.call(req).await - }) + Box::pin(self.inner.call(req).err_into::()) } } From f6b73acc4b706350cfc4fcdef7dbd04de32e4e5e Mon Sep 17 00:00:00 2001 From: Hossein Mayboudi Date: Wed, 27 Jan 2021 19:21:18 +0330 Subject: [PATCH 2/2] fix(examples): Fix tower examples Issue Number: #547 --- examples/src/tower/client.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/src/tower/client.rs b/examples/src/tower/client.rs index 1496daa76..0bcc8cd4d 100644 --- a/examples/src/tower/client.rs +++ b/examples/src/tower/client.rs @@ -1,6 +1,6 @@ use futures::TryFutureExt; -use hello_world::HelloRequest; use hello_world::greeter_client::GreeterClient; +use hello_world::HelloRequest; use service::AuthSvc; use tonic::transport::Channel;