pub struct RateLimiter { /* private fields */ }Expand description
Global rate limiter.
Provides rate limiting for GPU kernel requests with support for multiple algorithms and per-tenant limits.
Implementations§
Source§impl RateLimiter
impl RateLimiter
Sourcepub fn new(config: RateLimitConfig) -> Self
pub fn new(config: RateLimitConfig) -> Self
Create a new rate limiter with the given configuration.
Sourcepub fn check(&self) -> RateLimitResult<()>
pub fn check(&self) -> RateLimitResult<()>
Check if a request should be allowed (global limit).
Sourcepub fn check_tenant(&self, tenant_id: &str) -> RateLimitResult<()>
pub fn check_tenant(&self, tenant_id: &str) -> RateLimitResult<()>
Check if a request should be allowed for a specific tenant.
Sourcepub fn register_tenant(&self, tenant_id: &str, quota: u64)
pub fn register_tenant(&self, tenant_id: &str, quota: u64)
Register a tenant with a custom quota.
Sourcepub fn update_tenant_quota(
&self,
tenant_id: &str,
quota: u64,
) -> RateLimitResult<()>
pub fn update_tenant_quota( &self, tenant_id: &str, quota: u64, ) -> RateLimitResult<()>
Update a tenant’s quota.
Sourcepub fn remove_tenant(&self, tenant_id: &str) -> bool
pub fn remove_tenant(&self, tenant_id: &str) -> bool
Remove a tenant.
Sourcepub fn tenant_count(&self) -> usize
pub fn tenant_count(&self) -> usize
Get the number of registered tenants.
Sourcepub fn stats(&self) -> RateLimiterStatsSnapshot
pub fn stats(&self) -> RateLimiterStatsSnapshot
Get the current statistics.
Sourcepub fn reset_stats(&self)
pub fn reset_stats(&self)
Reset statistics.
Sourcepub fn config(&self) -> &RateLimitConfig
pub fn config(&self) -> &RateLimitConfig
Get the configuration.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if rate limiting is enabled.
Trait Implementations§
Source§impl RateLimiterExt for RateLimiter
impl RateLimiterExt for RateLimiter
Source§fn try_acquire(&self) -> RateLimitResult<RateLimitGuard<'_>>
fn try_acquire(&self) -> RateLimitResult<RateLimitGuard<'_>>
Try to acquire a rate limit guard.
Source§fn try_acquire_tenant(
&self,
tenant_id: &str,
) -> RateLimitResult<RateLimitGuard<'_>>
fn try_acquire_tenant( &self, tenant_id: &str, ) -> RateLimitResult<RateLimitGuard<'_>>
Try to acquire a tenant-scoped rate limit guard.
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> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Gets the layout of the type.