pub struct RateLimiterConfig {
pub capacity: usize,
pub refill_every: Duration,
pub max_wait: Duration,
}Expand description
限流器配置(令牌桶算法)。
§参数说明
capacity: 令牌桶容量(允许的最大突发连接数)refill_every: 令牌补充间隔(每次补充 1 个令牌)max_wait: 获取令牌的最大等待时间,超时则拒绝连接
§Examples
use silent::RateLimiterConfig;
use std::time::Duration;
let config = RateLimiterConfig {
capacity: 10,
refill_every: Duration::from_millis(10),
max_wait: Duration::from_secs(2),
};Fields§
§capacity: usize令牌桶容量(允许的最大突发连接数)
refill_every: Duration令牌补充间隔(每次补充 1 个令牌)
max_wait: Duration获取令牌的最大等待时间,超时则拒绝连接
Trait Implementations§
Source§impl Clone for RateLimiterConfig
impl Clone for RateLimiterConfig
Source§fn clone(&self) -> RateLimiterConfig
fn clone(&self) -> RateLimiterConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RateLimiterConfig
impl Debug for RateLimiterConfig
impl Copy for RateLimiterConfig
Auto Trait Implementations§
impl Freeze for RateLimiterConfig
impl RefUnwindSafe for RateLimiterConfig
impl Send for RateLimiterConfig
impl Sync for RateLimiterConfig
impl Unpin for RateLimiterConfig
impl UnwindSafe for RateLimiterConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more