Trait governor::state::direct::StreamRateLimitExt[][src]

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

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

Required methods

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.

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.

Implementors