pub struct RateLimiter { /* private fields */ }Expand description
Rate limiter with per-IP and per-client tracking
Implementations§
Source§impl RateLimiter
impl RateLimiter
Sourcepub fn New(config: RateLimitConfig) -> Self
pub fn New(config: RateLimitConfig) -> Self
Create a new rate limiter
Sourcepub async fn CheckIpRateLimit(&self, ip: &str) -> Result<bool>
pub async fn CheckIpRateLimit(&self, ip: &str) -> Result<bool>
Check if request from IP is allowed
Sourcepub async fn CheckClientRateLimit(&self, client_id: &str) -> Result<bool>
pub async fn CheckClientRateLimit(&self, client_id: &str) -> Result<bool>
Check if request from client is allowed
Sourcepub async fn CheckRateLimit(&self, ip: &str, client_id: &str) -> Result<bool>
pub async fn CheckRateLimit(&self, ip: &str, client_id: &str) -> Result<bool>
Check both IP and client rate limits
Sourcepub async fn GetIpStatus(&self, ip: &str) -> RateLimitStatus
pub async fn GetIpStatus(&self, ip: &str) -> RateLimitStatus
Get current rate limit status for IP
Sourcepub async fn GetClientStatus(&self, client_id: &str) -> RateLimitStatus
pub async fn GetClientStatus(&self, client_id: &str) -> RateLimitStatus
Get current rate limit status for client
Sourcepub async fn CleanupStaleBuckets(&self)
pub async fn CleanupStaleBuckets(&self)
Clean up old buckets
Sourcepub fn StartCleanupTask(&self) -> JoinHandle<()>
pub fn StartCleanupTask(&self) -> JoinHandle<()>
Start background cleanup task
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RateLimiter
impl !RefUnwindSafe for RateLimiter
impl Send for RateLimiter
impl Sync for RateLimiter
impl Unpin for RateLimiter
impl !UnwindSafe for RateLimiter
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Applies the layer to a service and wraps it in [
Layered].