cksac / dataloader-rs

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

Fallible .load() #35

Open Niedzwiedzw opened 2 years ago

Niedzwiedzw commented 2 years ago

shouldn't .load() return Result<HashMap<_, _>> rather than just the hashmap itself? this forces me to panic on failed db request...

cksac commented 2 years ago

is try_load suit your needs?

gpollo commented 10 months ago

When implementing BatchFn, the load method is not faillible. In my case, I need to do database calls that may fail. How are the errors expected to propagate? Return an empty HashMap?

I feel we probably need another type TryBatchFn with a try_load method.

cksac commented 10 months ago

currently, in case of DB fail, return an empty map, like this test https://github.com/cksac/dataloader-rs/blob/master/tests/cached.rs#L177

However, it will only return error (key not found) without the root cause. But I think it should be sufficient for most cases.