Skip to content

Commit

Permalink
fix: relax sync bound
Browse files Browse the repository at this point in the history
  • Loading branch information
TroyKomodo committed Jul 13, 2024
1 parent 325422e commit d6142b0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions foundations/src/batcher/dataloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl From<()> for UnitError {
}
}

pub trait Loader<S: BuildHasher + Default = RandomState> {
pub trait Loader<S: BuildHasher + Default = RandomState>: Send {
type Key: Clone + Eq + std::hash::Hash + Send + Sync;
type Value: Clone + Send + Sync;
type Error: Clone + std::error::Error + Send + Sync;
Expand All @@ -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> + Send, 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> + Send + 'static, 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> + Send, S: BuildHasher + Default + Send + Sync> BatchOperation for Wrapper<L, S> {
type Error = L::Error;
type Item = L::Key;
type Mode = BatcherDataloader<S>;
Expand All @@ -83,7 +83,7 @@ impl<L: Loader<S> + Send + Sync, S: BuildHasher + Default + Send + Sync> BatchOp
documents: <Self::Mode as super::BatchMode<Self>>::Input,
) -> impl std::future::Future<Output = Result<<Self::Mode as super::BatchMode<Self>>::OperationOutput, Self::Error>> + Send
{
async move { self.0.load(documents.into_iter().collect()).await }
self.0.load(documents.into_iter().collect())
}
}

Expand Down
2 changes: 1 addition & 1 deletion 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: Send {
type Item: Send + Sync;
type Response: Clone + Send + Sync;
type Error: Clone + std::fmt::Debug + Send + Sync;
Expand Down

0 comments on commit d6142b0

Please sign in to comment.