pub struct RouteControls { /* private fields */ }Expand description
A set of per-route load-control rules. Each route
adds a prefix → RouteLimit mapping; at request time the longest
matching prefix wins, so a specific /v1/projects/export rule overrides a
broad /v1 one. Cheap to clone (the semaphores are shared behind Arc).
Implementations§
Source§impl RouteControls
impl RouteControls
Sourcepub fn new() -> Self
pub fn new() -> Self
An empty rule set — with_route_controls with this is a no-op.
Sourcepub fn route(self, prefix: impl Into<String>, limit: RouteLimit) -> Self
pub fn route(self, prefix: impl Into<String>, limit: RouteLimit) -> Self
Apply limit to every request whose path starts with prefix. The
concurrency cap (if any) is materialised into one shared semaphore here,
so all requests to the route draw from the SAME budget.
Trait Implementations§
Source§impl Clone for RouteControls
impl Clone for RouteControls
Auto Trait Implementations§
impl Forget for RouteControls
impl Freeze for RouteControls
impl Move for RouteControls
impl RefUnwindSafe for RouteControls
impl Send for RouteControls
impl Sync for RouteControls
impl Unpin for RouteControls
impl UnsafeUnpin for RouteControls
impl UnwindSafe for RouteControls
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