diff options
-rw-r--r-- | tvix/castore/src/directoryservice/from_addr.rs | 11 | ||||
-rw-r--r-- | tvix/cli/src/main.rs | 5 | ||||
-rw-r--r-- | tvix/store/src/bin/tvix-store.rs | 21 |
3 files changed, 26 insertions, 11 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: {}", diff --git a/tvix/cli/src/main.rs b/tvix/cli/src/main.rs index 742bfe5ee66d..c367fecfac2c 100644 --- a/tvix/cli/src/main.rs +++ b/tvix/cli/src/main.rs @@ -80,7 +80,10 @@ async fn construct_services( let blob_service: Arc<dyn BlobService> = blobservice::from_addr(blob_service_addr.as_ref()) .await? .into(); - let directory_service = directoryservice::from_addr(directory_service_addr.as_ref()).await?; + let directory_service: Arc<dyn DirectoryService> = + directoryservice::from_addr(directory_service_addr.as_ref()) + .await? + .into(); let path_info_service = pathinfoservice::from_addr( path_info_service_addr.as_ref(), blob_service.clone(), diff --git a/tvix/store/src/bin/tvix-store.rs b/tvix/store/src/bin/tvix-store.rs index d00d5e304776..912417af8146 100644 --- a/tvix/store/src/bin/tvix-store.rs +++ b/tvix/store/src/bin/tvix-store.rs @@ -14,6 +14,7 @@ use tracing_subscriber::prelude::*; use tvix_castore::blobservice; use tvix_castore::blobservice::BlobService; use tvix_castore::directoryservice; +use tvix_castore::directoryservice::DirectoryService; use tvix_castore::import; use tvix_castore::proto::blob_service_server::BlobServiceServer; use tvix_castore::proto::directory_service_server::DirectoryServiceServer; @@ -197,7 +198,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { // initialize stores let blob_service: Arc<dyn BlobService> = blobservice::from_addr(&blob_service_addr).await?.into(); - let directory_service = directoryservice::from_addr(&directory_service_addr).await?; + let directory_service: Arc<dyn DirectoryService> = + directoryservice::from_addr(&directory_service_addr) + .await? + .into(); let path_info_service = pathinfoservice::from_addr( &path_info_service_addr, blob_service.clone(), @@ -253,7 +257,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { // FUTUREWORK: allow flat for single files? let blob_service: Arc<dyn BlobService> = blobservice::from_addr(&blob_service_addr).await?.into(); - let directory_service = directoryservice::from_addr(&directory_service_addr).await?; + let directory_service: Arc<dyn DirectoryService> = + directoryservice::from_addr(&directory_service_addr) + .await? + .into(); let path_info_service = pathinfoservice::from_addr( &path_info_service_addr, blob_service.clone(), @@ -356,7 +363,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { } => { let blob_service: Arc<dyn BlobService> = blobservice::from_addr(&blob_service_addr).await?.into(); - let directory_service = directoryservice::from_addr(&directory_service_addr).await?; + let directory_service: Arc<dyn DirectoryService> = + directoryservice::from_addr(&directory_service_addr) + .await? + .into(); let path_info_service = pathinfoservice::from_addr( &path_info_service_addr, blob_service.clone(), @@ -401,7 +411,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { } => { let blob_service: Arc<dyn BlobService> = blobservice::from_addr(&blob_service_addr).await?.into(); - let directory_service = directoryservice::from_addr(&directory_service_addr).await?; + let directory_service: Arc<dyn DirectoryService> = + directoryservice::from_addr(&directory_service_addr) + .await? + .into(); let path_info_service = pathinfoservice::from_addr( &path_info_service_addr, blob_service.clone(), |