about summary refs log tree commit diff
path: root/tvix/castore/src
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2023-12-31T14·26+0200
committerclbot <clbot@tvl.fyi>2023-12-31T22·18+0000
commit41935fab702f534ce7b787ef5f6e9f2ac2e7ce00 (patch)
treef71a64a30f20dd7eef4ddc5f3ee1a26983236a51 /tvix/castore/src
parent9ca1353122e6c1c5cf88d2ed5839fe385be1d5d0 (diff)
refactor(tvix/castore/directorysvc): return Box, not Arc r/7294
While we currently mostly use it in an Arc, as we need to clone it
inside PathInfoService, there might be other usecases not requiring it
to be Clone.

Change-Id: Ia05bb370340792a048e2036be30e285ef1e63870
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10483
Autosubmit: flokli <flokli@flokli.de>
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/castore/src')
-rw-r--r--tvix/castore/src/directoryservice/from_addr.rs11
1 files changed, 5 insertions, 6 deletions
diff --git a/tvix/castore/src/directoryservice/from_addr.rs b/tvix/castore/src/directoryservice/from_addr.rs
index bd1bf584cf29..0a5a0464c14a 100644
--- a/tvix/castore/src/directoryservice/from_addr.rs
+++ b/tvix/castore/src/directoryservice/from_addr.rs
@@ -1,4 +1,3 @@
-use std::sync::Arc;
 use url::Url;
 
 use crate::{proto::directory_service_client::DirectoryServiceClient, Error};
@@ -19,7 +18,7 @@ use super::{DirectoryService, GRPCDirectoryService, MemoryDirectoryService, Sled
 ///   Connects to a local tvix-store gRPC service via Unix socket.
 /// - `grpc+http://host:port`, `grpc+https://host:port`
 ///    Connects to a (remote) tvix-store gRPC service.
-pub async fn from_addr(uri: &str) -> Result<Arc<dyn DirectoryService>, crate::Error> {
+pub async fn from_addr(uri: &str) -> Result<Box<dyn DirectoryService>, crate::Error> {
     let url = Url::parse(uri)
         .map_err(|e| crate::Error::StorageError(format!("unable to parse url: {}", e)))?;
 
@@ -28,7 +27,7 @@ pub async fn from_addr(uri: &str) -> Result<Arc<dyn DirectoryService>, crate::Er
         if url.has_host() || !url.path().is_empty() {
             return Err(Error::StorageError("invalid url".to_string()));
         }
-        Arc::new(MemoryDirectoryService::default())
+        Box::<MemoryDirectoryService>::default()
     } else if url.scheme() == "sled" {
         // sled doesn't support host, and a path can be provided (otherwise
         // it'll live in memory only).
@@ -45,12 +44,12 @@ pub async fn from_addr(uri: &str) -> Result<Arc<dyn DirectoryService>, crate::Er
         // TODO: expose compression and other parameters as URL parameters?
 
         if url.path().is_empty() {
-            return Ok(Arc::new(
+            return Ok(Box::new(
                 SledDirectoryService::new_temporary()
                     .map_err(|e| Error::StorageError(e.to_string()))?,
             ));
         }
-        return Ok(Arc::new(
+        return Ok(Box::new(
             SledDirectoryService::new(url.path())
                 .map_err(|e| Error::StorageError(e.to_string()))?,
         ));
@@ -61,7 +60,7 @@ pub async fn from_addr(uri: &str) -> Result<Arc<dyn DirectoryService>, crate::Er
         // - In the case of non-unix sockets, there must be a host, but no path.
         // Constructing the channel is handled by tvix_castore::channel::from_url.
         let client = DirectoryServiceClient::new(crate::tonic::channel_from_url(&url).await?);
-        Arc::new(GRPCDirectoryService::from_client(client))
+        Box::new(GRPCDirectoryService::from_client(client))
     } else {
         Err(crate::Error::StorageError(format!(
             "unknown scheme: {}",