Expand description
Hybrid batching for efficient writes.
The HybridBatcher collects items and flushes them in batches based on
configurable thresholds: item count, total bytes, or elapsed time.
§Example
use sync_engine::{HybridBatcher, BatchConfig, SizedItem};
#[derive(Clone)]
struct Item { data: String }
impl SizedItem for Item {
fn size_bytes(&self) -> usize { self.data.len() }
}
let config = BatchConfig {
flush_ms: 100,
flush_count: 10,
flush_bytes: 1024,
};
let mut batcher: HybridBatcher<Item> = HybridBatcher::new(config);
assert!(batcher.is_empty());
batcher.add(Item { data: "hello".into() });
assert!(!batcher.is_empty());Structs§
- Batch
- A batch of items pending flush
- Batch
Config - Configuration for hybrid batching
- Flush
Batch - A batch of items ready for flush
- Hybrid
Batcher - Hybrid batcher that flushes based on time, count, or size thresholds. Whichever threshold is hit first triggers the flush.
Enums§
- Flush
Reason - Batch flush trigger reason
Traits§
- Batchable
Item - Trait for items that have an ID (for contains check)
- Sized
Item - Trait for items that know their own size