about summary refs log tree commit diff
path: root/tvix/store/src
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2023-02-15T13·00+0200
committerflokli <flokli@flokli.de>2023-03-10T10·58+0000
commit6b91efa5cf6d09e65dc06dfc56376b678eafa033 (patch)
tree919052b6117c24e21196f2d401bc09c10179e65e /tvix/store/src
parentcd22a8aa6d235465715382f2ab98e63cb54964b1 (diff)
refactor(tvix/store): use GRPC Wrappers and new services r/5922
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 <tvl@lahfa.xyz>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/store/src')
-rw-r--r--tvix/store/src/lib.rs3
-rw-r--r--tvix/store/src/main.rs37
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<dyn std::error::Error>> {
 
     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")]
     {