1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//! # Rate Limiter Module
//!
//! This module provides the internal implementation of the rate limiting functionality.
//! It's organized into several submodules, each responsible for a specific aspect
//! of the rate limiting system.
//!
//! ## Module Structure
//!
//! ```text
//! rate_limiter/
//! ├── mod.rs (You are here - Module organization)
//! ├── config.rs (Configuration and settings)
//! ├── core.rs (Core token bucket implementation)
//! ├── manager.rs (IP-based rate limiter management)
//! ├── metrics.rs (Performance monitoring)
//! └── utils.rs (Platform-specific optimizations)
//! ```
//!
//! ## Architecture Flow
//!
//! ```text
//! User Request
//! │
//! ▼
//! ┌─────────┐
//! │ Manager │ ◄── Per-IP rate limiting
//! └────┬────┘
//! │
//! ▼
//! ┌─────────┐
//! │ Core │ ◄── Token bucket algorithm
//! └────┬────┘
//! │
//! ▼
//! ┌─────────┐
//! │ Config │ ◄── Settings & validation
//! └────┬────┘
//! │
//! ▼
//! ┌─────────┐
//! │ Utils │ ◄── CPU optimizations
//! └─────────┘
//! ```
//!
//! ## Component Responsibilities
//!
//! - **config**: Defines how the rate limiter behaves (tokens, refill rate, etc.)
//! - **core**: Implements the lock-free token bucket using atomic operations
//! - **manager**: Manages multiple rate limiters for different IPs
//! - **metrics**: Tracks performance and health statistics
//! - **utils**: Provides platform-specific optimizations and helpers
// Declare submodules (internal organization)
// Re-export public types for external use
// These are the types that users of the library will interact with
/// Configuration types for customizing rate limiter behavior
pub use ;
/// Core rate limiter implementing the token bucket algorithm
pub use RateLimiter;
/// IP-based rate limiting manager for per-client limits
pub use ;
/// Metrics and health monitoring for observability
pub use ;
/// Utility functions for time and CPU optimizations
pub use ;