From 6b91efa5cf6d09e65dc06dfc56376b678eafa033 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Wed, 15 Feb 2023 15:00:27 +0200 Subject: refactor(tvix/store): use GRPC Wrappers and new services This swaps out the implementation used in the main entrypoint. We now use the non-gRPC aware Sled*Service, and wrap it with GRPC*ServiceWrapper to spin up the gRPC server. Change-Id: I5a1236c0612eee85e49891062040127c8bd95058 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8106 Reviewed-by: raitobezarius Tested-by: BuildkiteCI --- tvix/store/src/lib.rs | 3 +-- tvix/store/src/main.rs | 37 +++++++++++++++++++++++++++++-------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/tvix/store/src/lib.rs b/tvix/store/src/lib.rs index c275be5ff0ed..f23b0b9b8833 100644 --- a/tvix/store/src/lib.rs +++ b/tvix/store/src/lib.rs @@ -6,6 +6,7 @@ mod errors; pub mod blobservice; pub mod chunkservice; pub mod directoryservice; +pub mod nar; pub mod pathinfoservice; pub mod proto; @@ -15,7 +16,5 @@ pub mod sled_directory_service; pub mod sled_path_info_service; pub use errors::Error; -mod nar; - #[cfg(test)] mod tests; diff --git a/tvix/store/src/main.rs b/tvix/store/src/main.rs index 69b7722f8d7e..e71c1ef88614 100644 --- a/tvix/store/src/main.rs +++ b/tvix/store/src/main.rs @@ -1,6 +1,14 @@ +use tvix_store::blobservice::SledBlobService; +use tvix_store::chunkservice::SledChunkService; +use tvix_store::directoryservice::SledDirectoryService; +use tvix_store::nar::NonCachingNARCalculationService; +use tvix_store::pathinfoservice::SledPathInfoService; use tvix_store::proto::blob_service_server::BlobServiceServer; use tvix_store::proto::directory_service_server::DirectoryServiceServer; use tvix_store::proto::path_info_service_server::PathInfoServiceServer; +use tvix_store::proto::GRPCBlobServiceWrapper; +use tvix_store::proto::GRPCDirectoryServiceWrapper; +use tvix_store::proto::GRPCPathInfoServiceWrapper; #[cfg(feature = "reflection")] use tvix_store::proto::FILE_DESCRIPTOR_SET; @@ -34,16 +42,29 @@ async fn main() -> Result<(), Box> { let mut server = Server::builder(); - let blob_service = tvix_store::dummy_blob_service::DummyBlobService {}; - let directory_service = - tvix_store::sled_directory_service::SledDirectoryService::new("directories.sled".into())?; - let path_info_service = - tvix_store::sled_path_info_service::SledPathInfoService::new("pathinfo.sled".into())?; + let blob_service = SledBlobService::new("blobs.sled".into())?; + let chunk_service = SledChunkService::new("chunks.sled".into())?; + let directory_service = SledDirectoryService::new("directories.sled".into())?; + let path_info_service = SledPathInfoService::new("pathinfo.sled".into())?; + + let nar_calculation_service = NonCachingNARCalculationService::new( + blob_service.clone(), + chunk_service.clone(), + directory_service.clone(), + ); let mut router = server - .add_service(BlobServiceServer::new(blob_service)) - .add_service(DirectoryServiceServer::new(directory_service)) - .add_service(PathInfoServiceServer::new(path_info_service)); + .add_service(BlobServiceServer::new(GRPCBlobServiceWrapper::new( + blob_service, + chunk_service, + ))) + .add_service(DirectoryServiceServer::new( + GRPCDirectoryServiceWrapper::from(directory_service), + )) + .add_service(PathInfoServiceServer::new(GRPCPathInfoServiceWrapper::new( + path_info_service, + nar_calculation_service, + ))); #[cfg(feature = "reflection")] { -- cgit 1.4.1