cksac / dataloader-rs

Rust implementation of Facebook's DataLoader using async-await.
Apache License 2.0
261 stars 23 forks source link

feature request : BatchFn::load function takes &mut self instead of &self #23

Closed AtsukiTak closed 4 years ago

AtsukiTak commented 4 years ago

I love to use this crate! Thanks for creating!

Added feature

BatchFn::load function now able to take &mut self parameter. It brings more flexibility.

Why I need this

The BatchFn::load function needs to be mutable when I use tokio-postgres with this since Client::transaction function requires &mut self. Maybe we can use Mutex but it seems to me that BatchFn could easily be mutable.

Breaking change

The signature of BatchFn::load function is changed.

Thanks for reading!

cksac commented 4 years ago

ya, load_fn now is in Arc<Mutex<LoadFn>> of loader, should allow take &mut self. Thanks for the PR.