pub struct RateLimitMiddleware { /* private fields */ }Expand description
Token-bucket rate limiting middleware.
Implementations§
Source§impl RateLimitMiddleware
impl RateLimitMiddleware
Sourcepub fn new(max_requests_per_second: f64) -> RateLimitMiddleware
pub fn new(max_requests_per_second: f64) -> RateLimitMiddleware
Create a new rate limiter with a global requests-per-second limit.
Sourcepub fn with_tool_limit(self, tool_name: &str, limit: f64) -> RateLimitMiddleware
pub fn with_tool_limit(self, tool_name: &str, limit: f64) -> RateLimitMiddleware
Set a per-tool rate limit override.
Trait Implementations§
Source§impl Middleware for RateLimitMiddleware
impl Middleware for RateLimitMiddleware
Source§fn process_request<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
request: &'life1 JsonRpcRequest,
_ctx: &'life2 mut RequestContext,
) -> Pin<Box<dyn Future<Output = MiddlewareResult> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
RateLimitMiddleware: 'async_trait,
fn process_request<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
request: &'life1 JsonRpcRequest,
_ctx: &'life2 mut RequestContext,
) -> Pin<Box<dyn Future<Output = MiddlewareResult> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
RateLimitMiddleware: 'async_trait,
Process an incoming request. Return
Continue or Reject.Source§fn process_response<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_response: &'life1 mut JsonRpcResponse,
_ctx: &'life2 RequestContext,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn process_response<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_response: &'life1 mut JsonRpcResponse,
_ctx: &'life2 RequestContext,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Optionally process the outgoing response (no-op by default).
Auto Trait Implementations§
impl Freeze for RateLimitMiddleware
impl !RefUnwindSafe for RateLimitMiddleware
impl Send for RateLimitMiddleware
impl Sync for RateLimitMiddleware
impl Unpin for RateLimitMiddleware
impl UnsafeUnpin for RateLimitMiddleware
impl !UnwindSafe for RateLimitMiddleware
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