Skip to main content

Module refiller

Module refiller 

Source
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ยง

BandwidthRefiller
A bandwidth refiller is in charge of refilling the associated super::BandwidthPool and processing any pending refill requests that were enqueued by the pool.

Type Aliasesยง

BwRequest ๐Ÿ”’
A bandwidth request sent on the queue to the BandwidthRefiller.