1 unstable release

Uses new Rust 2024

new 0.1.0 May 4, 2025

#542 in Asynchronous

MIT/Apache

14KB
319 lines

Speedbump

Flexible and extensible rate limiting with batteries included implementations.

Concepts

The crate is built around two (user-definable) traits.

  • Store: Defines how the rate limiting state (e.g., counters, timestamps) is persisted. Implementations could include in-memory, Redis, or other storage backends.
  • Strategy: Defines the rate limiting algorithm (e.g., fixed window, token bucket) and how it uses the persisted state to determine if a request should be allowed or rate-limited.

These traits are used within a Limiter struct, which orchestrates the retrieval of state from the Store and the application of the Strategy to decide whether a request should be rejected or allowed. This Limiter can then be integrated into middleware.

Todo

  • Documentation
  • More examples
  • More strategies:
    • Sliding window
    • Token bucket
    • Leaky bucket
  • More stores:
    • Redis
    • Memcached
  • Middleware implementations:
    • Tower
    • Actix

Dependencies

~0.7–6MB
~31K SLoC