diff options
author | Florian Klink <flokli@flokli.de> | 2024-10-18T12·41+0200 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2024-10-18T21·45+0000 |
commit | 9c223450199b466c535f2b715ad68f1f295fa7dc (patch) | |
tree | 18834efec0cefeb1a6362095e6b2b4e7e094cfe1 /tvix/castore/src/directoryservice | |
parent | 47efebfc6fcbce028c0f3df5f9d584119e8e8ffe (diff) |
refactor(tvix/[ca]store): use auto_impl r/8835
This implements BS, DS, PS for Box'ed or Arc'ed variants of it with less code, and less potential to accidentially forget to proxy default trait methods for blanked impls, as fixed in cl/12658. Change-Id: If2cdbb563a73792038ebe7bff45d6f880214855b Reviewed-on: https://cl.tvl.fyi/c/depot/+/12661 Tested-by: BuildkiteCI Autosubmit: flokli <flokli@flokli.de> Reviewed-by: edef <edef@edef.eu>
Diffstat (limited to 'tvix/castore/src/directoryservice')
-rw-r--r-- | tvix/castore/src/directoryservice/combinators.rs | 4 | ||||
-rw-r--r-- | tvix/castore/src/directoryservice/mod.rs | 27 |
2 files changed, 4 insertions, 27 deletions
diff --git a/tvix/castore/src/directoryservice/combinators.rs b/tvix/castore/src/directoryservice/combinators.rs index 84216de92f90..4dfc19540c47 100644 --- a/tvix/castore/src/directoryservice/combinators.rs +++ b/tvix/castore/src/directoryservice/combinators.rs @@ -170,8 +170,8 @@ impl ServiceBuilder for CacheConfig { context: &CompositionContext, ) -> Result<Arc<dyn DirectoryService>, 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/castore/src/directoryservice/mod.rs b/tvix/castore/src/directoryservice/mod.rs index 76c7548d425a..b3cb0f4fd67b 100644 --- a/tvix/castore/src/directoryservice/mod.rs +++ b/tvix/castore/src/directoryservice/mod.rs @@ -1,6 +1,7 @@ use crate::composition::{Registry, ServiceBuilder}; use crate::{B3Digest, Directory, Error}; +use auto_impl::auto_impl; use futures::stream::BoxStream; use tonic::async_trait; mod combinators; @@ -39,6 +40,7 @@ pub use self::bigtable::{BigtableDirectoryService, BigtableParameters}; /// This is a simple get and put of [Directory], returning their /// digest. #[async_trait] +#[auto_impl(&, &mut, Arc, Box)] pub trait DirectoryService: Send + Sync { /// Looks up a single Directory message by its digest. /// The returned Directory message *must* be valid. @@ -80,31 +82,6 @@ pub trait DirectoryService: Send + Sync { fn put_multiple_start(&self) -> Box<dyn DirectoryPutter>; } -#[async_trait] -impl<A> DirectoryService for A -where - A: AsRef<dyn DirectoryService> + Send + Sync, -{ - async fn get(&self, digest: &B3Digest) -> Result<Option<Directory>, Error> { - self.as_ref().get(digest).await - } - - async fn put(&self, directory: Directory) -> Result<B3Digest, Error> { - self.as_ref().put(directory).await - } - - fn get_recursive( - &self, - root_directory_digest: &B3Digest, - ) -> BoxStream<'static, Result<Directory, Error>> { - self.as_ref().get_recursive(root_directory_digest) - } - - fn put_multiple_start(&self) -> Box<dyn DirectoryPutter> { - self.as_ref().put_multiple_start() - } -} - /// Provides a handle to put a closure of connected [Directory] elements. /// /// The consumer can periodically call [DirectoryPutter::put], starting from the |