diff options
author | Florian Klink <flokli@flokli.de> | 2023-09-05T12·22+0300 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2023-09-05T21·13+0000 |
commit | 7923cc19f698bdd128f93087d203cd6182b21ef2 (patch) | |
tree | 572174cd040a106e9fb5f25feb6ef4eae6b36b07 /tvix/store/src/directoryservice | |
parent | f499d2e031c100b6e1af53c8d77c045667ec1909 (diff) |
refactor(tvix/store): use tokio::task::JoinHandle r/6558
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 <flokli@flokli.de> Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/store/src/directoryservice')
-rw-r--r-- | tvix/store/src/directoryservice/grpc.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/tvix/store/src/directoryservice/grpc.rs b/tvix/store/src/directoryservice/grpc.rs index 22805523845d..73d88bb688a3 100644 --- a/tvix/store/src/directoryservice/grpc.rs +++ b/tvix/store/src/directoryservice/grpc.rs @@ -5,6 +5,7 @@ use crate::proto::{self, get_directory_request::ByWhat}; use crate::{B3Digest, Error}; use tokio::net::UnixStream; use tokio::sync::mpsc::UnboundedSender; +use tokio::task::JoinHandle; use tokio_stream::wrappers::UnboundedReceiverStream; use tonic::{transport::Channel, Status}; use tonic::{Code, Streaming}; @@ -162,7 +163,7 @@ impl DirectoryService for GRPCDirectoryService { // clone so we can move it let root_directory_digest_cpy = root_directory_digest.clone(); - let task: tokio::task::JoinHandle<Result<Streaming<proto::Directory>, Status>> = + let task: JoinHandle<Result<Streaming<proto::Directory>, Status>> = self.tokio_handle.spawn(async move { let s = grpc_client .get(proto::GetDirectoryRequest { @@ -193,7 +194,7 @@ impl DirectoryService for GRPCDirectoryService { let (tx, rx) = tokio::sync::mpsc::unbounded_channel(); - let task: tokio::task::JoinHandle<Result<proto::PutDirectoryResponse, Status>> = + let task: JoinHandle<Result<proto::PutDirectoryResponse, Status>> = self.tokio_handle.spawn(async move { let s = grpc_client .put(UnboundedReceiverStream::new(rx)) @@ -303,7 +304,7 @@ pub struct GRPCPutter { /// The task will yield a [proto::PutDirectoryResponse] once the stream is closed. #[allow(clippy::type_complexity)] // lol rq: Option<( - tokio::task::JoinHandle<Result<proto::PutDirectoryResponse, Status>>, + JoinHandle<Result<proto::PutDirectoryResponse, Status>>, UnboundedSender<proto::Directory>, )>, } @@ -312,7 +313,7 @@ impl GRPCPutter { pub fn new( tokio_handle: tokio::runtime::Handle, directory_sender: UnboundedSender<proto::Directory>, - task: tokio::task::JoinHandle<Result<proto::PutDirectoryResponse, Status>>, + task: JoinHandle<Result<proto::PutDirectoryResponse, Status>>, ) -> Self { Self { tokio_handle, |