diff options
author | Yureka <tvl@yuka.dev> | 2024-07-21T17·17+0200 |
---|---|---|
committer | yuka <tvl@yuka.dev> | 2024-07-22T13·36+0000 |
commit | 14a4b4cbc38f64c85475a759efc1a3c90003fb3d (patch) | |
tree | 84d713eabed9e0f2e4d0bb80864e5f7018f576e5 /tvix/store/src/utils.rs | |
parent | 67335c41b7828e11d28dead8193152da94116e6d (diff) |
feat(tvix): add experimental-store-composition option r/8400
Change-Id: I61661fbb0e77ce3c00c2a467dfabdf3fc77d8575 Reviewed-on: https://cl.tvl.fyi/c/depot/+/12011 Autosubmit: yuka <yuka@yuka.dev> Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/store/src/utils.rs')
-rw-r--r-- | tvix/store/src/utils.rs | 30 |
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(®, || 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 } |