stream_throttle 0.1.1

Provides a Stream combinator, to limit the rate at which items are produced.
Documentation

stream_throttle

Provides a Rust Stream combinator, to limit the rate at which items are produced.

Crates.io

Key Features

  • Throttling is implemented via poll(), and not via any sort of buffering.
  • The throttling behaviour can be applied to both Stream's and Future's.
  • Multiple streams/futures can be throttled together as a group.

Example throttling of Stream

let rate = ThrottleRate::new(5, Duration::new(2, 0));
let pool = ThrottlePool::new(rate, Timer::default());

stream::repeat(())
  .throttle(pool)
  .wait();

Example throttling of Future

let rate = ThrottleRate::new(5, Duration::new(2, 0));
let pool = ThrottlePool::new(rate, Timer::default());

pool.queue()
  .and_then(|_| Ok(()))
  .wait();