about summary refs log tree commit diff
path: root/tvix/store/src/bin
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/store/src/bin')
-rw-r--r--tvix/store/src/bin/tvix-store.rs62
1 files changed, 32 insertions, 30 deletions
diff --git a/tvix/store/src/bin/tvix-store.rs b/tvix/store/src/bin/tvix-store.rs
index 82c73f8f416c..99323d2a50a1 100644
--- a/tvix/store/src/bin/tvix-store.rs
+++ b/tvix/store/src/bin/tvix-store.rs
@@ -16,7 +16,6 @@ use tracing::{info, info_span, instrument, Level, Span};
 use tracing_indicatif::span_ext::IndicatifSpanExt as _;
 use tvix_castore::import::fs::ingest_path;
 use tvix_store::nar::NarCalculationService;
-use tvix_store::pathinfoservice::CachePathInfoService;
 use tvix_store::proto::NarInfo;
 use tvix_store::proto::PathInfo;
 
@@ -210,31 +209,38 @@ async fn run_cli(cli: Cli) -> Result<(), Box<dyn std::error::Error + Send + Sync
             remote_path_info_service_addr,
         } => {
             // initialize stores
-            let (blob_service, directory_service, path_info_service, nar_calculation_service) =
-                tvix_store::utils::construct_services(
-                    blob_service_addr,
-                    directory_service_addr,
-                    path_info_service_addr,
-                )
-                .await?;
+            let mut configs = tvix_store::utils::addrs_to_configs(
+                blob_service_addr,
+                directory_service_addr,
+                path_info_service_addr,
+            )?;
 
             // if remote_path_info_service_addr has been specified,
             // update path_info_service to point to a cache combining the two.
-            let path_info_service = if let Some(addr) = remote_path_info_service_addr {
-                let remote_path_info_service = tvix_store::pathinfoservice::from_addr(
-                    &addr,
-                    blob_service.clone(),
-                    directory_service.clone(),
-                )
-                .await?;
-
-                let path_info_service =
-                    CachePathInfoService::new(path_info_service, remote_path_info_service);
+            if let Some(addr) = remote_path_info_service_addr {
+                use tvix_store::composition::{with_registry, DeserializeWithRegistry, REG};
+                use tvix_store::pathinfoservice::CachePathInfoServiceConfig;
+
+                let remote_url = url::Url::parse(&addr)?;
+                let remote_config = with_registry(&REG, || remote_url.try_into())?;
+
+                let local = configs.pathinfoservices.insert(
+                    "default".into(),
+                    DeserializeWithRegistry(Box::new(CachePathInfoServiceConfig {
+                        near: "local".into(),
+                        far: "remote".into(),
+                    })),
+                );
+                configs
+                    .pathinfoservices
+                    .insert("local".into(), local.unwrap());
+                configs
+                    .pathinfoservices
+                    .insert("remote".into(), remote_config);
+            }
 
-                Box::new(path_info_service) as Box<dyn PathInfoService>
-            } else {
-                path_info_service
-            };
+            let (blob_service, directory_service, path_info_service, nar_calculation_service) =
+                tvix_store::utils::construct_services_from_configs(configs).await?;
 
             let mut server = Server::builder().layer(
                 ServiceBuilder::new()
@@ -257,7 +263,7 @@ async fn run_cli(cli: Cli) -> Result<(), Box<dyn std::error::Error + Send + Sync
                     GRPCDirectoryServiceWrapper::new(directory_service),
                 ))
                 .add_service(PathInfoServiceServer::new(GRPCPathInfoServiceWrapper::new(
-                    Arc::from(path_info_service),
+                    path_info_service,
                     nar_calculation_service,
                 )));
 
@@ -302,8 +308,7 @@ async fn run_cli(cli: Cli) -> Result<(), Box<dyn std::error::Error + Send + Sync
                 )
                 .await?;
 
-            // Arc PathInfoService and NarCalculationService, as we clone it .
-            let path_info_service: Arc<dyn PathInfoService> = path_info_service.into();
+            // Arc NarCalculationService, as we clone it .
             let nar_calculation_service: Arc<dyn NarCalculationService> =
                 nar_calculation_service.into();
 
@@ -365,9 +370,6 @@ async fn run_cli(cli: Cli) -> Result<(), Box<dyn std::error::Error + Send + Sync
             let reference_graph: ReferenceGraph<'_> =
                 serde_json::from_slice(reference_graph_json.as_slice())?;
 
-            // Arc the PathInfoService, as we clone it .
-            let path_info_service: Arc<dyn PathInfoService> = path_info_service.into();
-
             let lookups_span = info_span!(
                 "lookup pathinfos",
                 "indicatif.pb_show" = tracing::field::Empty
@@ -475,7 +477,7 @@ async fn run_cli(cli: Cli) -> Result<(), Box<dyn std::error::Error + Send + Sync
                 let fs = make_fs(
                     blob_service,
                     directory_service,
-                    Arc::from(path_info_service),
+                    path_info_service,
                     list_root,
                     show_xattr,
                 );
@@ -523,7 +525,7 @@ async fn run_cli(cli: Cli) -> Result<(), Box<dyn std::error::Error + Send + Sync
                 let fs = make_fs(
                     blob_service,
                     directory_service,
-                    Arc::from(path_info_service),
+                    path_info_service,
                     list_root,
                     show_xattr,
                 );