Skip to content

yawntee/rust-throttle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rust-throttle

rate limit library

use once_cell::sync::Lazy;

static THROTTLE: Lazy<Mutex<Throttle>> = Lazy::new(|| Throttle::new(Duration::from_secs(1), 10));

fn main(){
    if let Ok(mut throttle) = THROTTLE.lock() {
        if throttle.accept() {
            //will run if number of calls less than 10 times duration 1s
        }
    }
}

About

rate limit library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages