diff options
author | Florian Klink <flokli@flokli.de> | 2024-01-12T10·18+0200 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2024-01-12T20·37+0000 |
commit | b59df53774acc654ea4b23f02ccf5529587bceff (patch) | |
tree | fa35191cd12dbca2478884616de2527eb89066e2 /tvix/store/src/pathinfoservice/nix_http.rs | |
parent | 7d51193f7db8d6126ee2970eadf009a5d87b694f (diff) |
refactor(tvix/store/pathinfoservice): make more generic r/7371
We don't need Arcs in most of the cases, we're fine with some container. Change-Id: Ic4f8acb5b9d93e2b0923bb607463fb91e9d0e4fe Reviewed-on: https://cl.tvl.fyi/c/depot/+/10606 Autosubmit: flokli <flokli@flokli.de> Tested-by: BuildkiteCI Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Diffstat (limited to 'tvix/store/src/pathinfoservice/nix_http.rs')
-rw-r--r-- | tvix/store/src/pathinfoservice/nix_http.rs | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/tvix/store/src/pathinfoservice/nix_http.rs b/tvix/store/src/pathinfoservice/nix_http.rs index ddca35c67a0e..4929355c6dde 100644 --- a/tvix/store/src/pathinfoservice/nix_http.rs +++ b/tvix/store/src/pathinfoservice/nix_http.rs @@ -1,7 +1,6 @@ use std::{ io::{self, BufRead, Read, Write}, pin::Pin, - sync::Arc, }; use data_encoding::BASE64; @@ -38,24 +37,20 @@ use super::PathInfoService; /// [PathInfoService::put] and [PathInfoService::calculate_nar] are not /// implemented and return an error if called. /// TODO: what about reading from nix-cache-info? -pub struct NixHTTPPathInfoService { +pub struct NixHTTPPathInfoService<BS, DS> { base_url: url::Url, http_client: reqwest::Client, - blob_service: Arc<dyn BlobService>, - directory_service: Arc<dyn DirectoryService>, + blob_service: BS, + directory_service: DS, /// An optional list of [narinfo::PubKey]. /// If set, the .narinfo files received need to have correct signature by at least one of these. public_keys: Option<Vec<narinfo::PubKey>>, } -impl NixHTTPPathInfoService { - pub fn new( - base_url: url::Url, - blob_service: Arc<dyn BlobService>, - directory_service: Arc<dyn DirectoryService>, - ) -> Self { +impl<BS, DS> NixHTTPPathInfoService<BS, DS> { + pub fn new(base_url: url::Url, blob_service: BS, directory_service: DS) -> Self { Self { base_url, http_client: reqwest::Client::new(), @@ -73,7 +68,11 @@ impl NixHTTPPathInfoService { } #[async_trait] -impl PathInfoService for NixHTTPPathInfoService { +impl<BS, DS> PathInfoService for NixHTTPPathInfoService<BS, DS> +where + BS: AsRef<dyn BlobService> + Send + Sync + Clone + 'static, + DS: AsRef<dyn DirectoryService> + Send + Sync + Clone + 'static, +{ #[instrument(skip_all, err, fields(path.digest=BASE64.encode(&digest)))] async fn get(&self, digest: [u8; 20]) -> Result<Option<PathInfo>, Error> { let narinfo_url = self |