feat: add distributed rate limiting with sliding window algorithm

- RateLimiter trait with check_rate(key, config) -> RateResult
- InMemoryRateLimiter: DashMap-based sliding window log per key
- RateLimitConfig: configurable max_requests and window duration
- RateResult: allowed/remaining/retry_after_secs for Retry-After headers
- Lazy GC of expired entries (every 60s)
- Thread-safe concurrent access via DashMap
- 5 unit tests: limit enforcement, independent keys, remaining counter, concurrency
This commit is contained in:
2026-03-04 20:35:45 +01:00
parent e93a38243f
commit 913f6faaf3
2 changed files with 258 additions and 0 deletions

View File

@@ -17,4 +17,5 @@ pub mod groups;
pub mod p2p;
pub mod account;
pub mod moderation;
pub mod rate_limit;
pub mod recovery;