about summary refs log tree commit diff
path: root/tvix/store/src
diff options
context:
space:
mode:
authorYureka <tvl@yuka.dev>2024-08-07T17·18+0200
committeryuka <tvl@yuka.dev>2024-10-10T12·53+0000
commit07bf8a0b6d4541e1982968c03279a0491056ac2f (patch)
treefdf72473962ef82fcb0d148a79a22aad007cbdbd /tvix/store/src
parentae9ff35c32cbcfc865e651c92ddb5ad03158140b (diff)
feat(tvix/pathinfo/nixhttp): use ingest stores from url r/8783
This still defaults to the "default" services, but allows users to tell the
nix+http pathinfoservice to ingest the castore nodes into a non-default
blob-/directoryservice when used with the experimental store composition.

Change-Id: I5c0f683ce95d888eadf3f302520a47f42f1a481d
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12148
Reviewed-by: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/store/src')
-rw-r--r--tvix/store/src/pathinfoservice/nix_http.rs20
1 files changed, 18 insertions, 2 deletions
diff --git a/tvix/store/src/pathinfoservice/nix_http.rs b/tvix/store/src/pathinfoservice/nix_http.rs
index 5f1eed1a0a9f..2ff094858bc9 100644
--- a/tvix/store/src/pathinfoservice/nix_http.rs
+++ b/tvix/store/src/pathinfoservice/nix_http.rs
@@ -267,6 +267,7 @@ pub struct NixHTTPPathInfoServiceConfig {
 impl TryFrom<Url> for NixHTTPPathInfoServiceConfig {
     type Error = Box<dyn std::error::Error + Send + Sync>;
     fn try_from(url: Url) -> Result<Self, Self::Error> {
+        // Be careful about the distinction between `None` and `Some(vec![])`!
         let mut public_keys: Option<Vec<String>> = None;
         for (_, v) in url
             .query_pairs()
@@ -277,13 +278,28 @@ impl TryFrom<Url> for NixHTTPPathInfoServiceConfig {
                 .get_or_insert(Default::default())
                 .extend(v.split_ascii_whitespace().map(ToString::to_string));
         }
+
+        // FUTUREWORK: move url deserialization to serde?
+        let blob_service = url
+            .query_pairs()
+            .into_iter()
+            .find(|(k, _)| k == "blob_service")
+            .map(|(_, v)| v.to_string())
+            .unwrap_or("default".to_string());
+        let directory_service = url
+            .query_pairs()
+            .into_iter()
+            .find(|(k, _)| k == "directory_service")
+            .map(|(_, v)| v.to_string())
+            .unwrap_or("default".to_string());
+
         Ok(NixHTTPPathInfoServiceConfig {
             // Stringify the URL and remove the nix+ prefix.
             // We can't use `url.set_scheme(rest)`, as it disallows
             // setting something http(s) that previously wasn't.
             base_url: url.to_string().strip_prefix("nix+").unwrap().to_string(),
-            blob_service: "default".to_string(),
-            directory_service: "default".to_string(),
+            blob_service,
+            directory_service,
             public_keys,
         })
     }