about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2023-05-22T16·43+0300
committerclbot <clbot@tvl.fyi>2023-05-24T09·01+0000
commit8d392221c67760c7134718e324922b33660609cb (patch)
treebbde43147f953ab7a171c167a3e182b9a404b36e
parentf4a7b325e9d44fc2fd002e7cf2eb9361528017a9 (diff)
feat(tvix/store/directorysvc): GRPCDirectoryService::from_client r/6187
Change-Id: Ifa274a380683b01f0f24cd9ff1f50d22f13b38bd
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8612
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
Autosubmit: flokli <flokli@flokli.de>
-rw-r--r--tvix/store/src/directoryservice/grpc.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/tvix/store/src/directoryservice/grpc.rs b/tvix/store/src/directoryservice/grpc.rs
index 46e19224c7..1b33572cf7 100644
--- a/tvix/store/src/directoryservice/grpc.rs
+++ b/tvix/store/src/directoryservice/grpc.rs
@@ -32,6 +32,17 @@ impl GRPCDirectoryService {
             grpc_client,
         }
     }
+
+    /// construct a [GRPCDirectoryService] from a [proto::blob_service_client::BlobServiceClient<Channel>].
+    /// panics if called outside the context of a tokio runtime.
+    pub fn from_client(
+        grpc_client: proto::directory_service_client::DirectoryServiceClient<Channel>,
+    ) -> Self {
+        Self {
+            tokio_handle: tokio::runtime::Handle::current(),
+            grpc_client,
+        }
+    }
 }
 
 impl DirectoryService for GRPCDirectoryService {