pub struct FixedWindowStrategy {
pub max_requests: usize,
pub window_duration: Duration,
pub clients: DashMap<String, FixedWindowClientInfo>,
}Expand description
Fixed window rate limiting strategy
This strategy divides time into fixed windows and allows a fixed number of requests per window. When a window expires, the count resets.
Fields§
§max_requests: usizeMaximum requests per window
window_duration: DurationDuration of each window
clients: DashMap<String, FixedWindowClientInfo>Client tracking
Implementations§
Trait Implementations§
Source§impl Debug for FixedWindowStrategy
impl Debug for FixedWindowStrategy
Source§impl RateLimitStrategy for FixedWindowStrategy
impl RateLimitStrategy for FixedWindowStrategy
Source§fn check_rate_limit(&self, client_id: &str) -> Result<(), ToolError>
fn check_rate_limit(&self, client_id: &str) -> Result<(), ToolError>
Check if a request should be allowed for the given client Read more
Source§fn reset_client(&self, client_id: &str)
fn reset_client(&self, client_id: &str)
Reset rate limit state for a specific client
Source§fn get_request_count(&self, client_id: &str) -> usize
fn get_request_count(&self, client_id: &str) -> usize
Get current request count for a client
Source§fn strategy_name(&self) -> &str
fn strategy_name(&self) -> &str
Get strategy name for debugging/logging
Auto Trait Implementations§
impl Freeze for FixedWindowStrategy
impl !RefUnwindSafe for FixedWindowStrategy
impl Send for FixedWindowStrategy
impl Sync for FixedWindowStrategy
impl Unpin for FixedWindowStrategy
impl UnwindSafe for FixedWindowStrategy
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