From e53adc75bfbaee034febbe53b07db943db244ab8 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Thu, 13 Mar 2025 19:23:44 +0100 Subject: [PATCH] refactor(tvix/castore/directory/grpc): simplify put_multiple_start a bit We don't need to be as verbose with the types, we can use Ok::<_,Status> inside the async block. Change-Id: Ibc92a9f7bdbc5031806b7eca82a01e2c7cb48c0a Reviewed-on: https://cl.tvl.fyi/c/depot/+/13264 Autosubmit: flokli Reviewed-by: Ilan Joselevich Tested-by: BuildkiteCI --- tvix/castore/src/directoryservice/grpc.rs | 25 ++++++++++++----------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/tvix/castore/src/directoryservice/grpc.rs b/tvix/castore/src/directoryservice/grpc.rs index cc1710ac4..3889a6eea 100644 --- a/tvix/castore/src/directoryservice/grpc.rs +++ b/tvix/castore/src/directoryservice/grpc.rs @@ -196,21 +196,22 @@ where #[instrument(skip_all)] fn put_multiple_start(&self) -> Box<(dyn DirectoryPutter + 'static)> { - let mut grpc_client = self.grpc_client.clone(); - let (tx, rx) = tokio::sync::mpsc::unbounded_channel(); - let task: JoinHandle> = spawn( - async move { - let s = grpc_client - .put(UnboundedReceiverStream::new(rx)) - .await? - .into_inner(); + let task = spawn({ + let mut grpc_client = self.grpc_client.clone(); - Ok(s) - } // instrument the task with the current span, this is not done by default - .in_current_span(), - ); + async move { + Ok::<_, Status>( + grpc_client + .put(UnboundedReceiverStream::new(rx)) + .await? + .into_inner(), + ) + } + // instrument the task with the current span, this is not done by default + .in_current_span() + }); Box::new(GRPCPutter { rq: Some((task, tx)),