diff --git a/foundations/src/batcher/dataloader.rs b/foundations/src/batcher/dataloader.rs index edc59c493..864e2983a 100644 --- a/foundations/src/batcher/dataloader.rs +++ b/foundations/src/batcher/dataloader.rs @@ -41,11 +41,11 @@ pub trait Loader { fn load(&self, keys: Vec) -> impl std::future::Future> + Send; } -pub struct DataLoader + Send + Sync, S: BuildHasher + Default + Send + Sync = RandomState> { +pub struct DataLoader, S: BuildHasher + Default + Send + Sync = RandomState> { batcher: Batcher>, } -impl + Send + Sync + 'static, S: BuildHasher + Default + Send + Sync + 'static> DataLoader { +impl + 'static + Send + Sync, S: BuildHasher + Default + Send + Sync + 'static> DataLoader { pub fn new(loader: L) -> Self { Self { batcher: Batcher::new(Wrapper(loader, PhantomData)), @@ -68,7 +68,7 @@ impl + Send + Sync + 'static, S: BuildHasher + Default + Send + Syn struct Wrapper, S: BuildHasher + Default = RandomState>(L, PhantomData); -impl + Send + Sync, S: BuildHasher + Default + Send + Sync> BatchOperation for Wrapper { +impl, S: BuildHasher + Default + Send + Sync> BatchOperation for Wrapper { type Error = L::Error; type Item = L::Key; type Mode = BatcherDataloader; @@ -81,7 +81,7 @@ impl + Send + Sync, S: BuildHasher + Default + Send + Sync> BatchOp fn process( &self, documents: >::Input, - ) -> impl std::future::Future>::OperationOutput, Self::Error>> + Send + ) -> impl std::future::Future>::OperationOutput, Self::Error>> + Send + '_ where Self: Send + Sync { async move { self.0.load(documents.into_iter().collect()).await } } diff --git a/foundations/src/batcher/mod.rs b/foundations/src/batcher/mod.rs index 9ff007536..0ccd721e6 100644 --- a/foundations/src/batcher/mod.rs +++ b/foundations/src/batcher/mod.rs @@ -195,7 +195,7 @@ where } } -pub trait BatchOperation: Send + Sync { +pub trait BatchOperation { type Item: Send + Sync; type Response: Clone + Send + Sync; type Error: Clone + std::fmt::Debug + Send + Sync; @@ -206,7 +206,7 @@ pub trait BatchOperation: Send + Sync { fn process( &self, documents: >::Input, - ) -> impl std::future::Future>::OperationOutput, Self::Error>> + Send; + ) -> impl std::future::Future>::OperationOutput, Self::Error>> + Send + '_ where Self: Send + Sync; } pub struct Batcher { @@ -284,7 +284,7 @@ impl From for BatcherError { } } -impl Batch { +impl Batch { #[tracing::instrument(skip_all, fields(name = %inner.name))] async fn run(self, inner: Arc>) { self.results