Skip to content
explodingcameraPublic

About

A fast, memory-efficient rate limiter for Rust

Resources

Code of conduct

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Bottlecap

Crates.io   docs.rs

A fast, memory-efficient rate limiter for Rust.

use bottlecap::{Limiter, Quota};
let quota = Quota::per_second(10).with_burst(5);
let limiter = Limiter::new(quota);

// Consume one request, or return a retry delay.
assert!(limiter.check().is_ok());
assert!(limiter.check_n(2).is_ok());

// Check without using a request.
assert!(limiter.peek().is_ok());

// Wait for the next free request
limiter.wait(tokio::time::sleep).await?;

Integrations

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in bottlecap by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

A fast, memory-efficient rate limiter for Rust

Resources

Code of conduct

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages