[][src]Trait governor::prelude::StreamRateLimitExt

pub trait StreamRateLimitExt<'a>: Stream {
    fn ratelimit_stream<D: DirectStateStore, C: Clock>(
        self,
        limiter: &'a RateLimiter<NotKeyed, D, C>
    ) -> RatelimitedStream<'a, Self, D, C>
    where
        Self: Sized,
        C: ReasonablyRealtime
;
fn ratelimit_stream_with_jitter<D: DirectStateStore, C: Clock>(
        self,
        limiter: &'a RateLimiter<NotKeyed, D, C>,
        jitter: Jitter
    ) -> RatelimitedStream<'a, Self, D, C>
    where
        Self: Sized,
        C: ReasonablyRealtime
; }

Allows converting a [futures::Stream] combinator into a rate-limited stream.

Required methods

fn ratelimit_stream<D: DirectStateStore, C: Clock>(
    self,
    limiter: &'a RateLimiter<NotKeyed, D, C>
) -> RatelimitedStream<'a, Self, D, C> where
    Self: Sized,
    C: ReasonablyRealtime
[src]

Limits the rate at which the stream produces items.

Note that this combinator limits the rate at which it yields items, not necessarily the rate at which the underlying stream is polled. The combinator will buffer at most one item in order to adhere to the given limiter. I.e. if it already has an item buffered and needs to wait it will not poll the underlying stream.

fn ratelimit_stream_with_jitter<D: DirectStateStore, C: Clock>(
    self,
    limiter: &'a RateLimiter<NotKeyed, D, C>,
    jitter: Jitter
) -> RatelimitedStream<'a, Self, D, C> where
    Self: Sized,
    C: ReasonablyRealtime
[src]

Limits the rate at which the stream produces items, with a randomized wait period.

Note that this combinator limits the rate at which it yields items, not necessarily the rate at which the underlying stream is polled. The combinator will buffer at most one item in order to adhere to the given limiter. I.e. if it already has an item buffered and needs to wait it will not poll the underlying stream.

Loading content...

Implementors

impl<'a, S: Stream> StreamRateLimitExt<'a> for S[src]

Loading content...