#rate-limiting #rate #limit #limiter #quota

simple-rate-limit

以简单的数据结构执行速率限制,无需原子操作

2个不稳定版本

0.2.0 2020年8月15日
0.1.0 2020年8月11日

#1118数据结构

MPL-2.0 许可证

8KB

simple-rate-limit

License Package Documentation

#[test]
fn one_nanosecond() {
    let rl = RateLimit::new(1, Duration::from_nanos(1)).unwrap();
    let mut rler = RateLimiter::new(rl);
    let then = Instant::now();
    assert_eq!(rler.check_at(then), true);
    let now = then + Duration::from_nanos(2);
    assert_eq!(rler.check_at(now), true);
}

状态

测试版?只有基本测试,但似乎可以工作。

Copyright (c) 2020 James Laver, simple-rate-limit contributors.

This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.

依赖关系

~8KB