Skip to content

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

License

Notifications You must be signed in to change notification settings

lilymara-onesignal/stream-throttle

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stream_throttle

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

Crates.io API Documentation

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(1, 0));
let pool = ThrottlePool::new(rate);

let work = stream::repeat(())
  .throttle(pool)
  .for_each(|_| Ok(()));
  
tokio::run(work);

Example throttling of Future

let rate = ThrottleRate::new(5, Duration::new(1, 0));
let pool = ThrottlePool::new(rate);

let work = pool.queue()
  .then(|_| Ok(()));
  
tokio::run(work);

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 100.0%