Skip to main content

hyperlane_plugin_rate_limit/
lib.rs

1//! hyperlane-plugin-rate-limit
2//!
3//! 64-way sharded lock-free atomic GCRA and fixed-window rate limiter plugin
4//! for Hyperlane with extensible [`KeyExtractor`] and [`RateLimitStore`] traits
5//! and RFC `RateLimit-*` response headers.
6
7mod r#const;
8mod r#enum;
9mod r#fn;
10mod r#impl;
11mod r#static;
12mod r#struct;
13mod r#trait;
14mod r#type;
15
16#[cfg(test)]
17#[path = "../tests/mod.rs"]
18mod tests;
19
20pub use {r#const::*, r#enum::*, r#struct::*, r#trait::*};
21
22pub(crate) use {r#fn::*, r#static::*, r#type::*};
23
24use std::{
25    array::from_fn,
26    collections::{HashMap, VecDeque},
27    fmt::{self, Write},
28    hash::{BuildHasherDefault, Hasher},
29    net::{IpAddr, SocketAddr},
30    str::from_utf8,
31    sync::{
32        Arc, OnceLock, RwLock, RwLockReadGuard, RwLockWriteGuard,
33        atomic::{AtomicU64, AtomicUsize, Ordering},
34    },
35    time::Instant,
36};
37
38use {
39    hyperlane::{
40        Context, EMPTY_STR, HttpStatus, RETRY_AFTER, Request, Response, ResponseError, ServerHook,
41        Status, Stream, X_FORWARDED_FOR, X_REAL_IP,
42    },
43    lombok_macros::*,
44};