3 releases
Uses old Rust 2015
0.1.2 | Apr 21, 2018 |
---|---|
0.1.1 | Apr 21, 2018 |
0.1.0 | Apr 21, 2018 |
#8 in #acquire
10KB
156 lines
Rate limiter for rust. Acquire tokens as futures which are resolved when the token is ready.
Example Acquiring a Token
extern crate ratelimiter;
extern crate futures;
use ratelimiter::{RateLimiter, TokenFuture};
use futures::executor::ThreadPool;
use std::time::Duration;
use futures::FutureExt;
let mut rate_limiter = RateLimiter::new(1, 1, Duration::from_secs(1));
let token: TokenFuture = rate_limiter.acquire_token();
let and_then = token.and_then(|_| {
println!("Token acquired!");
return Ok(());
});
ThreadPool::new().unwrap().run(and_then);
Dependencies
~1MB
~15K SLoC