pub struct RateLimit { /* private fields */ }Expand description
Rate limiter plugin / route middleware.
Implementations§
Source§impl RateLimit
impl RateLimit
pub fn per_minute(max: usize) -> Self
Sourcepub fn max_entries(self, n: usize) -> Self
pub fn max_entries(self, n: usize) -> Self
Cap distinct client keys retained for local sliding (default 10_000).
Sourcepub fn message(self, msg: impl Into<String>) -> Self
pub fn message(self, msg: impl Into<String>) -> Self
429 response body (default "Too Many Requests").
Sourcepub fn key(self, key: RateLimitKey) -> Self
pub fn key(self, key: RateLimitKey) -> Self
Built-in key strategy (default RateLimitKey::Ip).
Sourcepub fn prefix(self, prefix: &'static str) -> Self
pub fn prefix(self, prefix: &'static str) -> Self
Prefix prepended to the resolved key (login:…, forgot:…).
Sourcepub fn fixed_window(
store: Arc<dyn KvStore>,
max: usize,
window: Duration,
) -> Self
pub fn fixed_window( store: Arc<dyn KvStore>, max: usize, window: Duration, ) -> Self
Multi-process / shared store: fixed window via atomic incr.
Like Self::fixed_window, using an installed sova_store::AppStore (rl namespace).
Sourcepub fn middleware(self) -> MwEntry
pub fn middleware(self) -> MwEntry
Route / mount middleware (same check as the plugin).
Trait Implementations§
Source§impl Plugin for RateLimit
impl Plugin for RateLimit
Source§fn id(&self) -> &'static str
fn id(&self) -> &'static str
Stable plugin identifier used for dependency checks and
crate::App::has_plugin. Read moreSource§fn meta(&self) -> PluginMeta
fn meta(&self) -> PluginMeta
Display name, description, and declared
PluginMeta::sdk version.Auto Trait Implementations§
impl !RefUnwindSafe for RateLimit
impl !UnwindSafe for RateLimit
impl Freeze for RateLimit
impl Send for RateLimit
impl Sync for RateLimit
impl Unpin for RateLimit
impl UnsafeUnpin for RateLimit
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more