From 22d06cc1c3a2e334f066e04f127b8e25a59df5cb Mon Sep 17 00:00:00 2001 From: ethe Date: Wed, 26 Oct 2022 12:01:57 +0800 Subject: [PATCH] remove useless liftetime paramenter in LoadBalance::InstancePicker --- examples/Cargo.toml | 6 +++--- examples/src/hello/grpc_client.rs | 4 +++- volo-grpc/src/layer/loadbalance/mod.rs | 1 - volo/src/loadbalance/layer.rs | 2 -- volo/src/loadbalance/mod.rs | 14 +++++++------- volo/src/loadbalance/random.rs | 16 ++++++++-------- 6 files changed, 21 insertions(+), 22 deletions(-) diff --git a/examples/Cargo.toml b/examples/Cargo.toml index da769e18..f79a54eb 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -18,9 +18,9 @@ path = "src/hello/grpc_server.rs" [[bin]] name = "hello-thrift-server" path = "src/hello/thrift_server.rs" -# [[bin]] -# name = "hello-thrift-client" -# path = "src/hello/thrift_client.rs" +[[bin]] +name = "hello-thrift-client" +path = "src/hello/thrift_client.rs" [dependencies] anyhow.workspace = true diff --git a/examples/src/hello/grpc_client.rs b/examples/src/hello/grpc_client.rs index cf5c2dd2..f73bb82f 100644 --- a/examples/src/hello/grpc_client.rs +++ b/examples/src/hello/grpc_client.rs @@ -15,7 +15,9 @@ lazy_static! { #[volo::main] async fn main() { - let req = volo_gen::proto_gen::hello::HelloRequest { name: "Volo".to_string() }; + let req = volo_gen::proto_gen::hello::HelloRequest { + name: "Volo".to_string(), + }; let resp = CLIENT.clone().hello(req).await; match resp { Ok(info) => println!("{:?}", info), diff --git a/volo-grpc/src/layer/loadbalance/mod.rs b/volo-grpc/src/layer/loadbalance/mod.rs index ef4e2b61..d704a22a 100644 --- a/volo-grpc/src/layer/loadbalance/mod.rs +++ b/volo-grpc/src/layer/loadbalance/mod.rs @@ -82,7 +82,6 @@ where LoadBalanceError: Into, S::Error: Debug, T: Send + 'static, - for<'future, 'iter> LB::GetFut<'future, 'iter>: Send, /* add this temporarily via https://github.com/rust-lang/rust/issues/100013 */ { type Response = S::Response; diff --git a/volo/src/loadbalance/layer.rs b/volo/src/loadbalance/layer.rs index 31ed1f6b..529e0c02 100644 --- a/volo/src/loadbalance/layer.rs +++ b/volo/src/loadbalance/layer.rs @@ -45,7 +45,6 @@ where impl Service for LoadBalanceService where - ::Config: std::marker::Sync, Cx: 'static + Context + Send + Sync, D: Discover, LB: LoadBalance, @@ -53,7 +52,6 @@ where LoadBalanceError: Into, S::Error: Debug + Retryable, Req: Clone + Send + Sync + 'static, - for<'future, 'iter> LB::GetFut<'future, 'iter>: Send, /* add this temporarily via https://github.com/rust-lang/rust/issues/100013 */ { type Response = S::Response; diff --git a/volo/src/loadbalance/mod.rs b/volo/src/loadbalance/mod.rs index 655fe24f..a7ebd7bc 100644 --- a/volo/src/loadbalance/mod.rs +++ b/volo/src/loadbalance/mod.rs @@ -17,24 +17,24 @@ where D: Discover, { /// `InstanceIter` is an iterator of [`crate::discovery::Instance`]. - type InstanceIter<'iter>: Iterator + Send + 'iter; + type InstanceIter: Iterator + Send; /// `GetFut` is the return type of `get_picker`. - type GetFut<'future, 'iter>: Future, LoadBalanceError>> + type GetFut<'future>: Future> + Send + 'future where - 'iter: 'future; + Self: 'future; /// `get_picker` allows to get an instance iterator of a specified endpoint from self or /// service discovery. - fn get_picker<'future, 'iter>( - &'iter self, + fn get_picker<'future>( + &'future self, endpoint: &'future Endpoint, discover: &'future D, - ) -> Self::GetFut<'future, 'iter> + ) -> Self::GetFut<'future> where - 'iter: 'future; + Self: 'future; /// `rebalance` is the callback method be used in service discovering subscription. fn rebalance(&self, changes: Change); } diff --git a/volo/src/loadbalance/random.rs b/volo/src/loadbalance/random.rs index f6f5c769..a7a1bafe 100644 --- a/volo/src/loadbalance/random.rs +++ b/volo/src/loadbalance/random.rs @@ -115,20 +115,20 @@ impl LoadBalance for WeightedRandomBalance where D: Discover, { - type InstanceIter<'iter> = InstancePicker; + type InstanceIter = InstancePicker; - type GetFut<'future, 'iter> = - impl Future, LoadBalanceError>> + Send + 'future + type GetFut<'future> = + impl Future> + Send + 'future where - 'iter: 'future; + Self: 'future; - fn get_picker<'future, 'iter>( - &'iter self, + fn get_picker<'future>( + &'future self, endpoint: &'future Endpoint, discover: &'future D, - ) -> Self::GetFut<'future, 'iter> + ) -> Self::GetFut<'future> where - 'iter: 'future, + Self: 'future, { async { let key = discover.key(endpoint);