From 7923cc19f698bdd128f93087d203cd6182b21ef2 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Tue, 5 Sep 2023 15:22:57 +0300 Subject: refactor(tvix/store): use tokio::task::JoinHandle This makes the inside code a bit less verbose. I wasn't able to describe the type of the async move closure itself, which would allow us to remove the JoinHandle<_> type annotation entirely. Change-Id: I06193982a0c7010bd72d3ffa4f760bea1b097632 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9268 Autosubmit: flokli Reviewed-by: tazjin Tested-by: BuildkiteCI --- tvix/store/src/blobservice/grpc.rs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'tvix/store/src/blobservice') diff --git a/tvix/store/src/blobservice/grpc.rs b/tvix/store/src/blobservice/grpc.rs index 71cde35cb21b..c6d28860f8aa 100644 --- a/tvix/store/src/blobservice/grpc.rs +++ b/tvix/store/src/blobservice/grpc.rs @@ -94,16 +94,15 @@ impl BlobService for GRPCBlobService { let mut grpc_client = self.grpc_client.clone(); let digest = digest.clone(); - let task: tokio::task::JoinHandle> = - self.tokio_handle.spawn(async move { - Ok(grpc_client - .stat(proto::StatBlobRequest { - digest: digest.into(), - ..Default::default() - }) - .await? - .into_inner()) - }); + let task: JoinHandle> = self.tokio_handle.spawn(async move { + Ok(grpc_client + .stat(proto::StatBlobRequest { + digest: digest.into(), + ..Default::default() + }) + .await? + .into_inner()) + }); match self.tokio_handle.block_on(task)? { Ok(_blob_meta) => Ok(true), @@ -122,7 +121,7 @@ impl BlobService for GRPCBlobService { // Construct the task that'll send out the request and return the stream // the gRPC client should use to send [proto::BlobChunk], or an error if // the blob doesn't exist. - let task: tokio::task::JoinHandle, Status>> = + let task: JoinHandle, Status>> = self.tokio_handle.spawn(async move { let stream = grpc_client .read(proto::ReadBlobRequest { @@ -172,7 +171,7 @@ impl BlobService for GRPCBlobService { let blobchunk_stream = ReceiverStream::new(rx).map(|x| proto::BlobChunk { data: x }); // That receiver stream is used as a stream in the gRPC BlobService.put rpc call. - let task: tokio::task::JoinHandle> = self + let task: JoinHandle> = self .tokio_handle .spawn(async move { Ok(grpc_client.put(blobchunk_stream).await?.into_inner()) }); -- cgit 1.4.1