Expand description
The refiller code that is the BandwidthRefiller is a public entity that needs to
run into its own task and refill the associated super::BandwidthPool and serve
any refill requests pending on the pool to be replenished.
ยงDriving a pool
The refiller must live in its own task that owns the clock and the rate. Simply call
BandwidthRefiller::run into a spawned task. It builds a token bucket from the given
rate + burst and a tor_rtcompat::SleepProvider.
ยงExample
โ
let (pool, refiller) = BandwidthPool::new(capacity, min_grant);
let config = TokenBucketConfig { rate, bucket_max: capacity };
runtime.spawn(refiller.run(runtime.clone(), config))?;Re-exportsยง
use futures::StreamExt as _;๐use futures::channel::mpsc;๐use std::num::NonZero;๐use std::sync::Arc;๐use tor_basic_utils::token_bucket::TokenBucket;๐use tor_basic_utils::token_bucket::TokenBucketConfig;๐use tor_rtcompat::SleepProvider;๐use super::bucket::AtomicTokenBucket;๐use super::reusable_oneshot;๐
Structsยง
- Bandwidth
Refiller - A bandwidth refiller is in charge of refilling the associated
super::BandwidthPooland processing any pending refill requests that were enqueued by the pool.
Type Aliasesยง
- BwRequest ๐
- A bandwidth request sent on the queue to the
BandwidthRefiller.