pub struct Windowed<L, S> { /* private fields */ }Expand description
A wrapper around a LimitAlgorithm which aggregates samples within a window, periodically updating the limit.
The window duration is dynamic, based on latencies seen in the previous window.
Various aggregators are available to aggregate samples.
Implementations§
Source§impl<L: LimitAlgorithm, S: Aggregator> Windowed<L, S>
impl<L: LimitAlgorithm, S: Aggregator> Windowed<L, S>
pub fn new(inner: L, sampler: S) -> Self
Sourcepub fn with_min_samples(self, samples: usize) -> Self
pub fn with_min_samples(self, samples: usize) -> Self
At least this many samples need to be aggregated before updating the limit.
Sourcepub fn with_min_window(self, min: Duration) -> Self
pub fn with_min_window(self, min: Duration) -> Self
Minimum time to wait before attempting to update the limit.
Sourcepub fn with_max_window(self, max: Duration) -> Self
pub fn with_max_window(self, max: Duration) -> Self
Maximum time to wait before attempting to update the limit.
Will wait for longer if not enough samples have been aggregated. See with_min_samples().
Trait Implementations§
Source§impl<L, S> LimitAlgorithm for Windowed<L, S>
impl<L, S> LimitAlgorithm for Windowed<L, S>
Auto Trait Implementations§
impl<L, S> !Freeze for Windowed<L, S>
impl<L, S> !RefUnwindSafe for Windowed<L, S>
impl<L, S> Send for Windowed<L, S>
impl<L, S> Sync for Windowed<L, S>
impl<L, S> Unpin for Windowed<L, S>
impl<L, S> UnwindSafe for Windowed<L, S>where
L: UnwindSafe,
S: UnwindSafe,
Blanket Implementations§
Source§impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
Source§fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
Convert the given value into an approximately equivalent representation.
Source§impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
Source§type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
The error type produced by a failed conversion.
Source§fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
Convert the subject into an approximately equivalent representation.
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
Source§impl<T, Dst> ConvAsUtil<Dst> for T
impl<T, Dst> ConvAsUtil<Dst> for T
Source§impl<T> ConvUtil for T
impl<T> ConvUtil for T
Source§fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
Approximate the subject to a given type with the default scheme.
Source§fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
Approximate the subject to a given type with a specific scheme.