about summary refs log tree commit diff
path: root/tvix/store/src/utils.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/store/src/utils.rs')
-rw-r--r--tvix/store/src/utils.rs30
1 files changed, 28 insertions, 2 deletions
diff --git a/tvix/store/src/utils.rs b/tvix/store/src/utils.rs
index 8f97651a03a5..4b07b35d694c 100644
--- a/tvix/store/src/utils.rs
+++ b/tvix/store/src/utils.rs
@@ -47,6 +47,13 @@ pub struct ServiceUrls {
 
     #[arg(long, env, default_value = "sled:///var/lib/tvix-store/pathinfo.sled")]
     path_info_service_addr: String,
+
+    /// Path to a TOML file describing the way the services should be composed
+    /// Experimental because the format is not final.
+    /// If specified, the other service addrs are ignored.
+    #[cfg(feature = "xp-store-composition")]
+    #[arg(long, env)]
+    experimental_store_composition: Option<String>,
 }
 
 /// like ServiceUrls, but with different clap defaults
@@ -60,6 +67,10 @@ pub struct ServiceUrlsGrpc {
 
     #[arg(long, env, default_value = "grpc+http://[::1]:8000")]
     path_info_service_addr: String,
+
+    #[cfg(feature = "xp-store-composition")]
+    #[arg(long, env)]
+    experimental_store_composition: Option<String>,
 }
 
 /// like ServiceUrls, but with different clap defaults
@@ -73,6 +84,10 @@ pub struct ServiceUrlsMemory {
 
     #[arg(long, env, default_value = "memory://")]
     path_info_service_addr: String,
+
+    #[cfg(feature = "xp-store-composition")]
+    #[arg(long, env)]
+    experimental_store_composition: Option<String>,
 }
 
 impl From<ServiceUrlsGrpc> for ServiceUrls {
@@ -81,6 +96,8 @@ impl From<ServiceUrlsGrpc> for ServiceUrls {
             blob_service_addr: urls.blob_service_addr,
             directory_service_addr: urls.directory_service_addr,
             path_info_service_addr: urls.path_info_service_addr,
+            #[cfg(feature = "xp-store-composition")]
+            experimental_store_composition: urls.experimental_store_composition,
         }
     }
 }
@@ -91,14 +108,23 @@ impl From<ServiceUrlsMemory> for ServiceUrls {
             blob_service_addr: urls.blob_service_addr,
             directory_service_addr: urls.directory_service_addr,
             path_info_service_addr: urls.path_info_service_addr,
+            #[cfg(feature = "xp-store-composition")]
+            experimental_store_composition: urls.experimental_store_composition,
         }
     }
 }
 
-pub fn addrs_to_configs(
+pub async fn addrs_to_configs(
     urls: impl Into<ServiceUrls>,
 ) -> Result<CompositionConfigs, Box<dyn std::error::Error + Send + Sync>> {
     let urls: ServiceUrls = urls.into();
+
+    #[cfg(feature = "xp-store-composition")]
+    if let Some(conf_path) = urls.experimental_store_composition {
+        let conf_text = tokio::fs::read_to_string(conf_path).await?;
+        return Ok(with_registry(&REG, || toml::from_str(&conf_text))?);
+    }
+
     let mut configs: CompositionConfigs = Default::default();
 
     let blob_service_url = Url::parse(&urls.blob_service_addr)?;
@@ -133,7 +159,7 @@ pub async fn construct_services(
     ),
     Box<dyn std::error::Error + Send + Sync>,
 > {
-    let configs = addrs_to_configs(urls)?;
+    let configs = addrs_to_configs(urls).await?;
     construct_services_from_configs(configs).await
 }