#rate-limiting #thread-safe #throttle #limiter #time #intervals #fixed

throttle2

A simple threadsafe throttle (rate limiter) that maintains fixed time intervals between ticks

2 releases

0.1.1 Mar 5, 2022
0.1.0 Mar 5, 2022

#17 in #throttle

MIT/Apache

14KB
189 lines

Cargo Build & Test

A simple threadsafe throttle (rate limiter) that maintains fixed time intervals between ticks.

Usage

use throttle2::Throttle;
use std::time::{Duration, SystemTime};

fn main() {
    let throttle = Throttle::from_cooldown(Duration::from_secs(10));

    println!("Hello world!");
    throttle.tick();
    println!("Hello again 10 seconds later");
    throttle.tick();
    println!("Hello again 10 more seconds later");
}

See [Throttle] documentation and the tests for more examples

No runtime deps