about summary refs log tree commit diff
path: root/tvix/store/src/bin/tvix-store.rs
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2023-06-09T15·22+0300
committerclbot <clbot@tvl.fyi>2023-06-12T10·24+0000
commitaa7bdc1199bfbb69091dda942a82812257e30bc4 (patch)
tree933964562f5746274ef6df59cfa956aca73b0807 /tvix/store/src/bin/tvix-store.rs
parent7725eb53ad67730e92a3839a6c10925c668e5586 (diff)
refactor(tvix/store): use Arc instead of Box r/6273
This allows us to blob services without closing them before putting them
in a box.
We currently need to use Arc<_>, not Rc<_>, because the GRPC wrappers
require Sync.

Change-Id: I679c5f06b62304f5b0456cfefe25a0a881de7c84
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8738
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Autosubmit: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/store/src/bin/tvix-store.rs')
-rw-r--r--tvix/store/src/bin/tvix-store.rs22
1 files changed, 10 insertions, 12 deletions
diff --git a/tvix/store/src/bin/tvix-store.rs b/tvix/store/src/bin/tvix-store.rs
index 4cedce6849d2..8cd87abe9c8c 100644
--- a/tvix/store/src/bin/tvix-store.rs
+++ b/tvix/store/src/bin/tvix-store.rs
@@ -100,16 +100,14 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
     match cli.command {
         Commands::Daemon { listen_address } => {
             // initialize stores
-            let blob_service = SledBlobService::new("blobs.sled".into())?;
-            let boxed_blob_service: Box<dyn BlobService> = Box::new(blob_service.clone());
-            let boxed_blob_service2: Box<dyn BlobService> = Box::new(blob_service.clone());
-            let directory_service = SledDirectoryService::new("directories.sled".into())?;
-            let boxed_directory_service = Box::new(directory_service.clone());
-            let boxed_directory_service2: Box<dyn DirectoryService> = Box::new(directory_service);
+            let blob_service: Arc<dyn BlobService> =
+                Arc::new(SledBlobService::new("blobs.sled".into())?);
+            let directory_service: Arc<dyn DirectoryService> =
+                Arc::new(SledDirectoryService::new("directories.sled".into())?);
             let path_info_service = SledPathInfoService::new(
                 "pathinfo.sled".into(),
-                boxed_blob_service,
-                boxed_directory_service,
+                blob_service.clone(),
+                directory_service.clone(),
             )?;
 
             let listen_address = listen_address
@@ -122,10 +120,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
             #[allow(unused_mut)]
             let mut router = server
                 .add_service(BlobServiceServer::new(GRPCBlobServiceWrapper::from(
-                    boxed_blob_service2,
+                    blob_service,
                 )))
                 .add_service(DirectoryServiceServer::new(
-                    GRPCDirectoryServiceWrapper::from(boxed_directory_service2),
+                    GRPCDirectoryServiceWrapper::from(directory_service),
                 ))
                 .add_service(PathInfoServiceServer::new(
                     GRPCPathInfoServiceWrapper::from(path_info_service),
@@ -156,8 +154,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
                 GRPCPathInfoService::from_client(path_info_service_client.clone());
 
             let io = Arc::new(TvixStoreIO::new(
-                Box::new(blob_service),
-                Box::new(directory_service),
+                Arc::new(blob_service),
+                Arc::new(directory_service),
                 path_info_service,
             ));