pub struct RateLimiterBuilder { /* private fields */ }Expand description
Fluent builder for one direction’s RateLimiterConfig.
ⓘ
.egress(|r| r
.bandwidth(1.mib(), Duration::from_secs(1))
.bandwidth_burst(512.kib())
.ops(1_000, Duration::from_secs(1))
.ops_burst(500)
)Implementations§
Source§impl RateLimiterBuilder
impl RateLimiterBuilder
Sourcepub fn bandwidth(self, size: impl Into<Bytes>, refill_time: Duration) -> Self
pub fn bandwidth(self, size: impl Into<Bytes>, refill_time: Duration) -> Self
Cap bandwidth at size bytes per refill_time.
refill_time must be at least one millisecond and exactly representable
as a whole number of milliseconds.
ⓘ
.bandwidth(1.mib(), Duration::from_secs(1))Sourcepub fn bandwidth_burst(self, burst: impl Into<Bytes>) -> Self
pub fn bandwidth_burst(self, burst: impl Into<Bytes>) -> Self
Grant a one-time startup burst of burst bytes on top of the
bandwidth bucket. Requires bandwidth.
Sourcepub fn ops(self, count: u64, refill_time: Duration) -> Self
pub fn ops(self, count: u64, refill_time: Duration) -> Self
Cap packet rate at count frames per refill_time.
refill_time must be at least one millisecond and exactly representable
as a whole number of milliseconds.
ⓘ
.ops(1_000, Duration::from_secs(1))Sourcepub fn ops_burst(self, count: u64) -> Self
pub fn ops_burst(self, count: u64) -> Self
Grant a one-time startup burst of count frames on top of the ops
bucket. Requires ops.
Sourcepub fn build(self) -> Result<RateLimiterConfig, BuildError>
pub fn build(self) -> Result<RateLimiterConfig, BuildError>
Consume the builder and return the validated configuration.
Auto Trait Implementations§
impl Freeze for RateLimiterBuilder
impl RefUnwindSafe for RateLimiterBuilder
impl Send for RateLimiterBuilder
impl Sync for RateLimiterBuilder
impl Unpin for RateLimiterBuilder
impl UnsafeUnpin for RateLimiterBuilder
impl UnwindSafe for RateLimiterBuilder
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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