carpool
Deduplicate and batch concurrent async requests.
Concurrent requests within a collection window are merged into a single downstream batch,
and duplicate inputs share one result. No cache; built on tokio.
Status
The crate is built and released feature by feature.
-
queue- the pending-request queue underneath the batching side: entries pair an input with itsoneshotreply sender, liveness is read lazily from the channel, batches are sliced by timer or by threshold. -
Deduplicator- single-flight per input over a user-implementedFetcher; a flight lives while at least one caller is still waiting. -
Batcher- collection-window batching over a user-implementedBatchCollector, with an input-addressed result contract. -
Loader- deduplication in front of batching. - Metrics - instrumentation of windows, batches, and flights.
- Tracing - OpenTelemetry spans linked to individual
loadcalls.
An earlier prototype of the whole stack lives on the draft branch.
Usage
cargo add carpool
cargo add tokio --features macros,rt-multi-thread,sync,time
The queue stores pending requests and slices batches; delivery stays with the consumer:
use Queue;
use oneshot;
async
A runnable walkthrough lives in the repository: cargo run --example queue.
Full API documentation is on docs.rs.
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.