feat(tvix): add experimental-store-composition option
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>
This commit is contained in:
parent
67335c41b7
commit
14a4b4cbc3
5 changed files with 230 additions and 52 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue