diff options
Diffstat (limited to 'tvix/store/src/pathinfoservice')
-rw-r--r-- | tvix/store/src/pathinfoservice/combinators.rs | 4 | ||||
-rw-r--r-- | tvix/store/src/pathinfoservice/fs/mod.rs | 11 | ||||
-rw-r--r-- | tvix/store/src/pathinfoservice/mod.rs | 24 | ||||
-rw-r--r-- | tvix/store/src/pathinfoservice/nix_http.rs | 10 | ||||
-rw-r--r-- | tvix/store/src/pathinfoservice/signing_wrapper.rs | 2 |
5 files changed, 15 insertions, 36 deletions
diff --git a/tvix/store/src/pathinfoservice/combinators.rs b/tvix/store/src/pathinfoservice/combinators.rs index 1f413cf310a2..f386fd52dc3c 100644 --- a/tvix/store/src/pathinfoservice/combinators.rs +++ b/tvix/store/src/pathinfoservice/combinators.rs @@ -88,8 +88,8 @@ impl ServiceBuilder for CacheConfig { context: &CompositionContext, ) -> Result<Arc<dyn PathInfoService>, Box<dyn std::error::Error + Send + Sync + 'static>> { let (near, far) = futures::join!( - context.resolve(self.near.clone()), - context.resolve(self.far.clone()) + context.resolve::<Self::Output>(self.near.clone()), + context.resolve::<Self::Output>(self.far.clone()) ); Ok(Arc::new(Cache { near: near?, diff --git a/tvix/store/src/pathinfoservice/fs/mod.rs b/tvix/store/src/pathinfoservice/fs/mod.rs index d996ec9f6f76..ea30a2f6477c 100644 --- a/tvix/store/src/pathinfoservice/fs/mod.rs +++ b/tvix/store/src/pathinfoservice/fs/mod.rs @@ -20,9 +20,9 @@ pub fn make_fs<BS, DS, PS>( show_xattr: bool, ) -> TvixStoreFs<BS, DS, RootNodesWrapper<PS>> where - BS: AsRef<dyn BlobService> + Send + Clone + 'static, - DS: AsRef<dyn DirectoryService> + Send + Clone + 'static, - PS: AsRef<dyn PathInfoService> + Send + Sync + Clone + 'static, + BS: BlobService + Send + Clone + 'static, + DS: DirectoryService + Send + Clone + 'static, + PS: PathInfoService + Send + Sync + Clone + 'static, { TvixStoreFs::new( blob_service, @@ -46,7 +46,7 @@ pub struct RootNodesWrapper<T>(pub(crate) T); #[async_trait] impl<T> RootNodes for RootNodesWrapper<T> where - T: AsRef<dyn PathInfoService> + Send + Sync, + T: PathInfoService + Send + Sync, { async fn get_by_basename(&self, name: &PathComponent) -> Result<Option<Node>, Error> { let Ok(store_path) = StorePathRef::from_bytes(name.as_ref()) else { @@ -55,14 +55,13 @@ where Ok(self .0 - .as_ref() .get(*store_path.digest()) .await? .map(|path_info| path_info.node)) } fn list(&self) -> BoxStream<Result<(PathComponent, Node), Error>> { - Box::pin(self.0.as_ref().list().map(|result| { + Box::pin(self.0.list().map(|result| { result.map(|path_info| { let basename = path_info.store_path.to_string(); ( diff --git a/tvix/store/src/pathinfoservice/mod.rs b/tvix/store/src/pathinfoservice/mod.rs index a0c48f5cc9d5..d31a1e652e3b 100644 --- a/tvix/store/src/pathinfoservice/mod.rs +++ b/tvix/store/src/pathinfoservice/mod.rs @@ -13,6 +13,7 @@ mod fs; #[cfg(test)] mod tests; +use auto_impl::auto_impl; use futures::stream::BoxStream; use tonic::async_trait; use tvix_castore::composition::{Registry, ServiceBuilder}; @@ -45,6 +46,7 @@ pub use self::fs::make_fs; /// The base trait all PathInfo services need to implement. #[async_trait] +#[auto_impl(&, &mut, Arc, Box)] pub trait PathInfoService: Send + Sync { /// Retrieve a PathInfo message by the output digest. async fn get(&self, digest: [u8; 20]) -> Result<Option<PathInfo>, Error>; @@ -69,28 +71,6 @@ pub trait PathInfoService: Send + Sync { } } -#[async_trait] -impl<A> PathInfoService for A -where - A: AsRef<dyn PathInfoService> + Send + Sync + 'static, -{ - async fn get(&self, digest: [u8; 20]) -> Result<Option<PathInfo>, Error> { - self.as_ref().get(digest).await - } - - async fn put(&self, path_info: PathInfo) -> Result<PathInfo, Error> { - self.as_ref().put(path_info).await - } - - fn list(&self) -> BoxStream<'static, Result<PathInfo, Error>> { - self.as_ref().list() - } - - fn nar_calculation_service(&self) -> Option<Box<dyn NarCalculationService>> { - self.as_ref().nar_calculation_service() - } -} - /// Registers the builtin PathInfoService implementations with the registry pub(crate) fn register_pathinfo_services(reg: &mut Registry) { reg.register::<Box<dyn ServiceBuilder<Output = dyn PathInfoService>>, CachePathInfoServiceConfig>("cache"); diff --git a/tvix/store/src/pathinfoservice/nix_http.rs b/tvix/store/src/pathinfoservice/nix_http.rs index ed386f0e9d14..29e04aa45867 100644 --- a/tvix/store/src/pathinfoservice/nix_http.rs +++ b/tvix/store/src/pathinfoservice/nix_http.rs @@ -66,8 +66,8 @@ impl<BS, DS> NixHTTPPathInfoService<BS, DS> { #[async_trait] 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, + BS: BlobService + Send + Sync + Clone + 'static, + DS: DirectoryService + Send + Sync + Clone + 'static, { #[instrument(skip_all, err, fields(path.digest=nixbase32::encode(&digest)))] async fn get(&self, digest: [u8; 20]) -> Result<Option<PathInfo>, Error> { @@ -316,10 +316,10 @@ impl ServiceBuilder for NixHTTPPathInfoServiceConfig { &'a self, _instance_name: &str, context: &CompositionContext, - ) -> Result<Arc<dyn PathInfoService>, Box<dyn std::error::Error + Send + Sync + 'static>> { + ) -> Result<Arc<Self::Output>, Box<dyn std::error::Error + Send + Sync + 'static>> { let (blob_service, directory_service) = futures::join!( - context.resolve(self.blob_service.clone()), - context.resolve(self.directory_service.clone()) + context.resolve::<dyn BlobService>(self.blob_service.clone()), + context.resolve::<dyn DirectoryService>(self.directory_service.clone()) ); let mut svc = NixHTTPPathInfoService::new( Url::parse(&self.base_url)?, diff --git a/tvix/store/src/pathinfoservice/signing_wrapper.rs b/tvix/store/src/pathinfoservice/signing_wrapper.rs index 4dff23722888..5898a5baa463 100644 --- a/tvix/store/src/pathinfoservice/signing_wrapper.rs +++ b/tvix/store/src/pathinfoservice/signing_wrapper.rs @@ -96,7 +96,7 @@ impl ServiceBuilder for KeyFileSigningPathInfoServiceConfig { _instance_name: &str, context: &CompositionContext, ) -> Result<Arc<dyn PathInfoService>, Box<dyn std::error::Error + Send + Sync + 'static>> { - let inner = context.resolve(self.inner.clone()).await?; + let inner = context.resolve::<Self::Output>(self.inner.clone()).await?; let signing_key = Arc::new( parse_keypair(tokio::fs::read_to_string(&self.keyfile).await?.trim()) .map_err(|e| Error::StorageError(e.to_string()))? |