https://github.com/alexheretic/benjamin-batchly
Low latency batching tool. Bundle lots of single concurrent operations into sequential batches of work.
https://github.com/alexheretic/benjamin-batchly
Last synced: 4 days ago
JSON representation
Low latency batching tool. Bundle lots of single concurrent operations into sequential batches of work.
- Host: GitHub
- URL: https://github.com/alexheretic/benjamin-batchly
- Owner: alexheretic
- License: apache-2.0
- Created: 2022-06-04T16:04:38.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-04-12T08:09:53.000Z (about 2 years ago)
- Last Synced: 2023-09-19T13:28:57.923Z (over 1 year ago)
- Language: Rust
- Size: 16.6 KB
- Stars: 6
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# benjamin_batchly [](https://crates.io/crates/benjamin_batchly) [](https://docs.rs/benjamin_batchly)
Low latency batching tool. Bundle lots of single concurrent operations into sequential batches of work.```rust
use benjamin_batchly::{BatchMutex, BatchResult};let batcher = BatchMutex::default();
// BatchMutex synchronizes so only one `Work` happens at a time (for a given batch_key).
// All concurrent submissions made while an existing `Work` is being processed will
// await completion and form the next `Work` batch.
match batcher.submit(batch_key, item).await {
BatchResult::Work(mut batch) => {
db_bulk_insert(&batch.items).await?;
batch.notify_all_done();
Ok(())
}
BatchResult::Done(_) => Ok(()),
BatchResult::Failed => Err("failed"),
}
```