From b46274ff762dab7fa724b6dfae94740008f526f5 Mon Sep 17 00:00:00 2001 From: Yukiteru Date: Sat, 2 Nov 2024 00:12:38 +0800 Subject: [PATCH 1/2] chore: fix nightly clippy rule `needless_lifetimes` (#516) ``` error: the following explicit lifetimes could be elided: 's, 'cx --> volo/src/loadbalance/layer.rs:60:19 | 60 | async fn call<'s, 'cx>( | ^^ ^^^ 61 | &'s self, | ^^ 62 | cx: &'cx mut Cx, | ^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes = note: `-D clippy::needless-lifetimes` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::needless_lifetimes)]` ``` Signed-off-by: Yu Li --- scripts/clippy-and-test.sh | 2 +- scripts/selftest.sh | 2 +- scripts/volo-cli-test.sh | 2 +- volo-grpc/src/client/meta.rs | 6 +++--- volo-grpc/src/client/mod.rs | 10 +++++----- volo-grpc/src/layer/cross_origin.rs | 6 +++--- volo-grpc/src/layer/grpc_timeout.rs | 6 +++--- volo-grpc/src/layer/loadbalance/mod.rs | 6 +----- volo-grpc/src/layer/user_agent.rs | 6 +++--- volo-grpc/src/server/router.rs | 6 +++--- volo-grpc/src/server/service.rs | 6 +++--- volo-grpc/src/transport/client.rs | 6 +++--- volo-http/src/utils/extension.rs | 6 +----- volo-thrift/src/client/layer/timeout.rs | 6 +----- volo-thrift/src/client/mod.rs | 16 ++++++---------- volo-thrift/src/server/layer/biz_error.rs | 6 +----- volo-thrift/src/transport/multiplex/client.rs | 6 +++--- volo-thrift/src/transport/pingpong/client.rs | 6 +++--- volo/src/loadbalance/layer.rs | 6 +----- 19 files changed, 46 insertions(+), 70 deletions(-) diff --git a/scripts/clippy-and-test.sh b/scripts/clippy-and-test.sh index b374ded7..0d064184 100644 --- a/scripts/clippy-and-test.sh +++ b/scripts/clippy-and-test.sh @@ -5,7 +5,7 @@ set -o nounset set -o pipefail echo_command() { - echo "Running $@" + echo "$@" if [ "${GITHUB_ACTIONS:-}" = "true" ] || [ -n "${DEBUG:-}" ]; then # If we are in GitHub Actions or env `DEBUG` is non-empty, diff --git a/scripts/selftest.sh b/scripts/selftest.sh index 86a07ca3..1c13a49b 100755 --- a/scripts/selftest.sh +++ b/scripts/selftest.sh @@ -5,7 +5,7 @@ set -o nounset set -o pipefail echo_and_run() { - echo "Running $@" + echo "$@" if [ -n "${DEBUG:-}" ]; then # If env `DEBUG` is non-empty, output all diff --git a/scripts/volo-cli-test.sh b/scripts/volo-cli-test.sh index 994111dc..76cd7527 100644 --- a/scripts/volo-cli-test.sh +++ b/scripts/volo-cli-test.sh @@ -9,7 +9,7 @@ quiet() { } echo_command() { - echo "Run \`$@\`" + echo "\`$@\`" if [ "${GITHUB_ACTIONS:-}" = "true" ] || [ -n "${DEBUG:-}" ]; then # If we are in GitHub Actions or env `DEBUG` is non-empty, diff --git a/volo-grpc/src/client/meta.rs b/volo-grpc/src/client/meta.rs index deabc7e1..ee96cc77 100644 --- a/volo-grpc/src/client/meta.rs +++ b/volo-grpc/src/client/meta.rs @@ -35,9 +35,9 @@ where type Error = S::Error; - async fn call<'s, 'cx>( - &'s self, - cx: &'cx mut ClientContext, + async fn call( + &self, + cx: &mut ClientContext, mut volo_req: Request, ) -> Result { let metadata = volo_req.metadata_mut(); diff --git a/volo-grpc/src/client/mod.rs b/volo-grpc/src/client/mod.rs index 8f4d8795..43aa7eed 100644 --- a/volo-grpc/src/client/mod.rs +++ b/volo-grpc/src/client/mod.rs @@ -590,9 +590,9 @@ macro_rules! impl_client { type Response = S::Response; type Error = S::Error; - async fn call<'s, 'cx>( - &'s $self, - $cx: &'cx mut crate::context::ClientContext, + async fn call( + &$self, + $cx: &mut crate::context::ClientContext, $req: Req, ) -> Result { $e @@ -613,9 +613,9 @@ macro_rules! impl_client { type Response = S::Response; type Error = S::Error; - async fn call<'cx>( + async fn call( $self, - $cx: &'cx mut crate::context::ClientContext, + $cx: &mut crate::context::ClientContext, $req: Req, ) -> Result { $e diff --git a/volo-grpc/src/layer/cross_origin.rs b/volo-grpc/src/layer/cross_origin.rs index 304f8903..4d560582 100644 --- a/volo-grpc/src/layer/cross_origin.rs +++ b/volo-grpc/src/layer/cross_origin.rs @@ -24,9 +24,9 @@ where type Response = T::Response; type Error = T::Error; - async fn call<'s, 'cx>( - &'s self, - cx: &'cx mut Cx, + async fn call( + &self, + cx: &mut Cx, req: Request, ) -> Result { // split the header and body diff --git a/volo-grpc/src/layer/grpc_timeout.rs b/volo-grpc/src/layer/grpc_timeout.rs index b3a57808..4275f379 100644 --- a/volo-grpc/src/layer/grpc_timeout.rs +++ b/volo-grpc/src/layer/grpc_timeout.rs @@ -95,9 +95,9 @@ where type Response = S::Response; type Error = Status; - async fn call<'s, 'cx>( - &'s self, - cx: &'cx mut Cx, + async fn call( + &self, + cx: &mut Cx, req: hyper::Request, ) -> Result { // parse the client_timeout diff --git a/volo-grpc/src/layer/loadbalance/mod.rs b/volo-grpc/src/layer/loadbalance/mod.rs index d867efaa..3695b819 100644 --- a/volo-grpc/src/layer/loadbalance/mod.rs +++ b/volo-grpc/src/layer/loadbalance/mod.rs @@ -87,11 +87,7 @@ where type Error = S::Error; - async fn call<'s, 'cx>( - &'s self, - cx: &'cx mut Cx, - req: Request, - ) -> Result { + async fn call(&self, cx: &mut Cx, req: Request) -> Result { let callee = cx.rpc_info().callee(); let mut picker = match &callee.address { diff --git a/volo-grpc/src/layer/user_agent.rs b/volo-grpc/src/layer/user_agent.rs index 3e6bc796..5061294f 100644 --- a/volo-grpc/src/layer/user_agent.rs +++ b/volo-grpc/src/layer/user_agent.rs @@ -35,9 +35,9 @@ where type Response = T::Response; type Error = T::Error; - async fn call<'s, 'cx>( - &'s self, - cx: &'cx mut Cx, + async fn call( + &self, + cx: &mut Cx, mut req: Request, ) -> Result { req.headers_mut() diff --git a/volo-grpc/src/server/router.rs b/volo-grpc/src/server/router.rs index 40063033..e5d42b39 100644 --- a/volo-grpc/src/server/router.rs +++ b/volo-grpc/src/server/router.rs @@ -94,9 +94,9 @@ where type Response = Response; type Error = Status; - async fn call<'s, 'cx>( - &'s self, - cx: &'cx mut ServerContext, + async fn call( + &self, + cx: &mut ServerContext, req: Request, ) -> Result { let path = cx.rpc_info.method(); diff --git a/volo-grpc/src/server/service.rs b/volo-grpc/src/server/service.rs index 7e950e6a..1694f4a6 100644 --- a/volo-grpc/src/server/service.rs +++ b/volo-grpc/src/server/service.rs @@ -121,9 +121,9 @@ where type Response = Response; type Error = Status; - async fn call<'s, 'cx>( - &'s self, - cx: &'cx mut ServerContext, + async fn call( + &self, + cx: &mut ServerContext, req: Request, ) -> Result { let (metadata, extensions, body) = req.into_parts(); diff --git a/volo-grpc/src/transport/client.rs b/volo-grpc/src/transport/client.rs index 0b3bac31..dcbe9774 100644 --- a/volo-grpc/src/transport/client.rs +++ b/volo-grpc/src/transport/client.rs @@ -115,9 +115,9 @@ where type Error = Status; - async fn call<'s, 'cx>( - &'s self, - cx: &'cx mut ClientContext, + async fn call( + &self, + cx: &mut ClientContext, volo_req: Request, ) -> Result { let mut http_client = self.http_client.clone(); diff --git a/volo-http/src/utils/extension.rs b/volo-http/src/utils/extension.rs index d7ea467d..897d8d23 100644 --- a/volo-http/src/utils/extension.rs +++ b/volo-http/src/utils/extension.rs @@ -62,11 +62,7 @@ where type Response = S::Response; type Error = S::Error; - async fn call<'s, 'cx>( - &'s self, - cx: &'cx mut Cx, - req: Req, - ) -> Result { + async fn call(&self, cx: &mut Cx, req: Req) -> Result { cx.extensions_mut().insert(self.ext.clone()); self.inner.call(cx, req).await } diff --git a/volo-thrift/src/client/layer/timeout.rs b/volo-thrift/src/client/layer/timeout.rs index 129e500d..098c6509 100644 --- a/volo-thrift/src/client/layer/timeout.rs +++ b/volo-thrift/src/client/layer/timeout.rs @@ -20,11 +20,7 @@ where type Error = S::Error; - async fn call<'s, 'cx>( - &'s self, - cx: &'cx mut ClientContext, - req: Req, - ) -> Result { + async fn call(&self, cx: &mut ClientContext, req: Req) -> Result { match cx.rpc_info.config().rpc_timeout() { Some(duration) => { let start = std::time::Instant::now(); diff --git a/volo-thrift/src/client/mod.rs b/volo-thrift/src/client/mod.rs index 20f56189..bb96c1b9 100644 --- a/volo-thrift/src/client/mod.rs +++ b/volo-thrift/src/client/mod.rs @@ -529,11 +529,7 @@ where type Error = ClientError; - async fn call<'s, 'cx>( - &'s self, - cx: &'cx mut ClientContext, - req: Req, - ) -> Result { + async fn call(&self, cx: &mut ClientContext, req: Req) -> Result { let msg = ThriftMessage::mk_client_msg(cx, req); let resp = self.inner.call(cx, msg).await; if self.read_biz_error { @@ -742,9 +738,9 @@ macro_rules! impl_client { type Response = S::Response; type Error = S::Error; - async fn call<'s, 'cx>( - &'s $self, - $cx: &'cx mut crate::context::ClientContext, + async fn call( + &$self, + $cx: &mut crate::context::ClientContext, $req: Req, ) -> Result { $e @@ -766,9 +762,9 @@ macro_rules! impl_client { type Response = S::Response; type Error = S::Error; - async fn call<'cx>( + async fn call( $self, - $cx: &'cx mut crate::context::ClientContext, + $cx: &mut crate::context::ClientContext, $req: Req, ) -> Result { $e diff --git a/volo-thrift/src/server/layer/biz_error.rs b/volo-thrift/src/server/layer/biz_error.rs index 02b5d5b9..28ce41b6 100644 --- a/volo-thrift/src/server/layer/biz_error.rs +++ b/volo-thrift/src/server/layer/biz_error.rs @@ -42,11 +42,7 @@ where type Error = crate::ServerError; #[inline] - async fn call<'s, 'cx>( - &'s self, - cx: &'cx mut ServerContext, - req: Req, - ) -> Result { + async fn call(&self, cx: &mut ServerContext, req: Req) -> Result { let ret = self.inner.call(cx, req).await.map_err(Into::into); if let Err(ServerError::Biz(err)) = ret.as_ref() { cx.common_stats.set_biz_error(err.clone()); diff --git a/volo-thrift/src/transport/multiplex/client.rs b/volo-thrift/src/transport/multiplex/client.rs index dd07fe86..959110c3 100644 --- a/volo-thrift/src/transport/multiplex/client.rs +++ b/volo-thrift/src/transport/multiplex/client.rs @@ -124,9 +124,9 @@ where type Error = ClientError; - async fn call<'cx, 's>( - &'s self, - cx: &'cx mut ClientContext, + async fn call( + &self, + cx: &mut ClientContext, req: ThriftMessage, ) -> Result { let rpc_info = &cx.rpc_info; diff --git a/volo-thrift/src/transport/pingpong/client.rs b/volo-thrift/src/transport/pingpong/client.rs index a3c942be..b6352030 100644 --- a/volo-thrift/src/transport/pingpong/client.rs +++ b/volo-thrift/src/transport/pingpong/client.rs @@ -106,9 +106,9 @@ where type Error = crate::ClientError; #[inline] - async fn call<'s, 'cx>( - &'s self, - cx: &'cx mut ClientContext, + async fn call( + &self, + cx: &mut ClientContext, req: ThriftMessage, ) -> Result { let rpc_info = &cx.rpc_info; diff --git a/volo/src/loadbalance/layer.rs b/volo/src/loadbalance/layer.rs index a17cf9e0..e0faefc2 100644 --- a/volo/src/loadbalance/layer.rs +++ b/volo/src/loadbalance/layer.rs @@ -57,11 +57,7 @@ where type Error = S::Error; - async fn call<'s, 'cx>( - &'s self, - cx: &'cx mut Cx, - req: Req, - ) -> Result { + async fn call(&self, cx: &mut Cx, req: Req) -> Result { let callee = cx.rpc_info().callee(); let picker = match &callee.address { From e9ab2fd1f9efab227023cbb775158ddcc8a5ed95 Mon Sep 17 00:00:00 2001 From: LIU JIE Date: Mon, 4 Nov 2024 11:59:10 +0800 Subject: [PATCH 2/2] fix(volo): make sure hotrestart sockdir exists (#517) --- volo/src/hotrestart/mod.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/volo/src/hotrestart/mod.rs b/volo/src/hotrestart/mod.rs index 869c55c6..8cd0f4ff 100644 --- a/volo/src/hotrestart/mod.rs +++ b/volo/src/hotrestart/mod.rs @@ -128,6 +128,9 @@ impl HotRestart { if *state != HotRestartState::Uninitalized { return Ok(()); } + if !sock_dir_path.exists() { + std::fs::create_dir_all(sock_dir_path)?; + } self.listener_num .store(server_listener_num, Ordering::Relaxed); self.parent_sock_path