Skip to content

Commit

Permalink
fix: fix bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
TroyKomodo committed Jul 13, 2024
1 parent 1ee5ec1 commit fc252a5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions foundations/src/batcher/dataloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ pub trait Loader<S: BuildHasher + Default = RandomState> {
fn load(&self, keys: Vec<Self::Key>) -> impl std::future::Future<Output = LoaderOutput<Self, S>> + Send;
}

pub struct DataLoader<L: Loader<S> + Send + Sync, S: BuildHasher + Default + Send + Sync = RandomState> {
pub struct DataLoader<L: Loader<S>, S: BuildHasher + Default + Send + Sync = RandomState> {
batcher: Batcher<Wrapper<L, S>>,
}

impl<L: Loader<S> + Send + Sync + 'static, S: BuildHasher + Default + Send + Sync + 'static> DataLoader<L, S> {
impl<L: Loader<S> + 'static + Send + Sync, S: BuildHasher + Default + Send + Sync + 'static> DataLoader<L, S> {
pub fn new(loader: L) -> Self {
Self {
batcher: Batcher::new(Wrapper(loader, PhantomData)),
Expand All @@ -68,7 +68,7 @@ impl<L: Loader<S> + Send + Sync + 'static, S: BuildHasher + Default + Send + Syn

struct Wrapper<L: Loader<S>, S: BuildHasher + Default = RandomState>(L, PhantomData<S>);

impl<L: Loader<S> + Send + Sync, S: BuildHasher + Default + Send + Sync> BatchOperation for Wrapper<L, S> {
impl<L: Loader<S>, S: BuildHasher + Default + Send + Sync> BatchOperation for Wrapper<L, S> {
type Error = L::Error;
type Item = L::Key;
type Mode = BatcherDataloader<S>;
Expand All @@ -81,7 +81,7 @@ impl<L: Loader<S> + Send + Sync, S: BuildHasher + Default + Send + Sync> BatchOp
fn process(
&self,
documents: <Self::Mode as super::BatchMode<Self>>::Input,
) -> impl std::future::Future<Output = Result<<Self::Mode as super::BatchMode<Self>>::OperationOutput, Self::Error>> + Send
) -> impl std::future::Future<Output = Result<<Self::Mode as super::BatchMode<Self>>::OperationOutput, Self::Error>> + Send + '_ where Self: Send + Sync
{
async move { self.0.load(documents.into_iter().collect()).await }
}
Expand Down
6 changes: 3 additions & 3 deletions foundations/src/batcher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -206,7 +206,7 @@ pub trait BatchOperation: Send + Sync {
fn process(
&self,
documents: <Self::Mode as BatchMode<Self>>::Input,
) -> impl std::future::Future<Output = Result<<Self::Mode as BatchMode<Self>>::OperationOutput, Self::Error>> + Send;
) -> impl std::future::Future<Output = Result<<Self::Mode as BatchMode<Self>>::OperationOutput, Self::Error>> + Send + '_ where Self: Send + Sync;
}

pub struct Batcher<T: BatchOperation> {
Expand Down Expand Up @@ -284,7 +284,7 @@ impl<E: std::error::Error> From<E> for BatcherError<E> {
}
}

impl<T: BatchOperation + 'static> Batch<T> {
impl<T: BatchOperation + 'static + Send + Sync> Batch<T> {
#[tracing::instrument(skip_all, fields(name = %inner.name))]
async fn run(self, inner: Arc<BatcherInner<T>>) {
self.results
Expand Down

0 comments on commit fc252a5

Please sign in to comment.