about summary refs log tree commit diff
path: root/tvix/store
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/store')
-rw-r--r--tvix/store/src/bin/tvix-store.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/tvix/store/src/bin/tvix-store.rs b/tvix/store/src/bin/tvix-store.rs
index 04b4c7a6aab0..9512a4483e75 100644
--- a/tvix/store/src/bin/tvix-store.rs
+++ b/tvix/store/src/bin/tvix-store.rs
@@ -16,6 +16,7 @@ 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;
 
@@ -83,6 +84,12 @@ enum Commands {
 
         #[arg(long, env, default_value = "sled:///var/lib/tvix-store/pathinfo.sled")]
         path_info_service_addr: String,
+
+        /// URL to a PathInfoService that's considered "remote".
+        /// If set, the other one is considered "local", and a "cache" for the
+        /// "remote" one.
+        #[arg(long, env)]
+        remote_path_info_service_addr: Option<String>,
     },
     /// Imports a list of paths into the store, print the store path for each of them.
     Import {
@@ -200,6 +207,7 @@ async fn run_cli(cli: Cli) -> Result<(), Box<dyn std::error::Error>> {
             blob_service_addr,
             directory_service_addr,
             path_info_service_addr,
+            remote_path_info_service_addr,
         } => {
             // initialize stores
             let (blob_service, directory_service, path_info_service, nar_calculation_service) =
@@ -210,6 +218,24 @@ async fn run_cli(cli: Cli) -> Result<(), Box<dyn std::error::Error>> {
                 )
                 .await?;
 
+            // 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);
+
+                Box::new(path_info_service) as Box<dyn PathInfoService>
+            } else {
+                path_info_service
+            };
+
             let mut server = Server::builder().layer(
                 ServiceBuilder::new()
                     .layer(