From 8d05c0ceaa9bddb7fdaab436730f093eb16374a2 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Thu, 8 Jun 2023 23:00:37 +0300 Subject: refactor(tvix/src/nar): drop NARCalculationService There's only one way to calculate NAR files, by walking through them. Things like caching such replies should be done closer to where we use these, composing NARCalculationService doesn't actually give us much. Instead, expose two functions, `nar::calculate_size_and_sha256` and `nar::writer_nar`, the latter writing NAR to a writer, the former using write_nar to only keeping the NAR size and digest. Change-Id: Ie5d2cfea35470fdbb5cbf9da1136b0cdf0250266 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8723 Reviewed-by: tazjin Tested-by: BuildkiteCI Autosubmit: flokli --- tvix/store/src/bin/tvix-store.rs | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'tvix/store/src/bin/tvix-store.rs') diff --git a/tvix/store/src/bin/tvix-store.rs b/tvix/store/src/bin/tvix-store.rs index 8fe62e5b5b2e..49c8c9ec34eb 100644 --- a/tvix/store/src/bin/tvix-store.rs +++ b/tvix/store/src/bin/tvix-store.rs @@ -11,8 +11,6 @@ use tvix_store::blobservice::GRPCBlobService; use tvix_store::blobservice::SledBlobService; use tvix_store::directoryservice::GRPCDirectoryService; use tvix_store::directoryservice::SledDirectoryService; -use tvix_store::nar::GRPCNARCalculationService; -use tvix_store::nar::NonCachingNARCalculationService; use tvix_store::pathinfoservice::GRPCPathInfoService; use tvix_store::pathinfoservice::SledPathInfoService; use tvix_store::proto::blob_service_client::BlobServiceClient; @@ -102,6 +100,8 @@ async fn main() -> Result<(), Box> { Commands::Daemon { listen_address } => { // initialize stores let blob_service = SledBlobService::new("blobs.sled".into())?; + let boxed_blob_service: Box = Box::new(blob_service.clone()); + let boxed_blob_service2: Box = Box::new(blob_service); let directory_service = SledDirectoryService::new("directories.sled".into())?; let path_info_service = SledPathInfoService::new("pathinfo.sled".into())?; @@ -112,22 +112,18 @@ async fn main() -> Result<(), Box> { let mut server = Server::builder(); - let nar_calculation_service = NonCachingNARCalculationService::new( - Box::new(blob_service.clone()), - directory_service.clone(), - ); - #[allow(unused_mut)] let mut router = server .add_service(BlobServiceServer::new(GRPCBlobServiceWrapper::from( - Box::new(blob_service) as Box, + boxed_blob_service, ))) .add_service(DirectoryServiceServer::new( - GRPCDirectoryServiceWrapper::from(directory_service), + GRPCDirectoryServiceWrapper::from(directory_service.clone()), )) .add_service(PathInfoServiceServer::new(GRPCPathInfoServiceWrapper::new( path_info_service, - nar_calculation_service, + boxed_blob_service2, + directory_service, ))); #[cfg(feature = "reflection")] @@ -153,14 +149,11 @@ async fn main() -> Result<(), Box> { PathInfoServiceClient::connect("http://[::1]:8000").await?; let path_info_service = GRPCPathInfoService::from_client(path_info_service_client.clone()); - let nar_calculation_service = - GRPCNARCalculationService::from_client(path_info_service_client); let io = Arc::new(TvixStoreIO::new( Box::new(blob_service), directory_service, path_info_service, - nar_calculation_service, )); let tasks = paths -- cgit 1.4.1