crates/utils/re_quota_channel/README.md
Part of the Rerun project.
A mpsc channel that applies backpressure based on byte size.
This crate provides a multi-producer, single-consumer channel that limits throughput based on the total byte size of messages in the channel, rather than just the number of messages.
When the byte capacity is exceeded:
send method blocks until space is availableuse re_quota_channel::channel;
// Create a channel with 1MB capacity
let (tx, rx) = channel::<Vec<u8>>("my_channel", 1_000_000);
// Send a message with its size
let data = vec![0u8; 1000];
tx.send(data.clone()).unwrap();
// Receive the message
let received = rx.recv().unwrap();
If a message is larger than the total channel capacity, a warning is logged and the channel waits until it's completely empty before sending (to minimize memory usage).