pub struct RpsController { /* private fields */ }Expand description
RPS (Requests Per Second) controller
Controls request rate to maintain a target RPS.
Implementations§
Source§impl RpsController
impl RpsController
Sourcepub async fn set_target_rps(&self, rps: f64)
pub async fn set_target_rps(&self, rps: f64)
Set target RPS
Sourcepub async fn get_target_rps(&self) -> f64
pub async fn get_target_rps(&self) -> f64
Get target RPS
Sourcepub async fn get_current_rps(&self) -> f64
pub async fn get_current_rps(&self) -> f64
Get current RPS (calculated over last second)
Sourcepub async fn wait_for_slot(&self)
pub async fn wait_for_slot(&self)
Wait for next request slot (rate limiting)
This will sleep if necessary to maintain the target RPS.
Sourcepub async fn record_request(&self)
pub async fn record_request(&self)
Record a request
Updates the current RPS calculation.
Sourcepub async fn get_request_count(&self) -> u64
pub async fn get_request_count(&self) -> u64
Get request count since last reset
Trait Implementations§
Source§impl Clone for RpsController
impl Clone for RpsController
Source§fn clone(&self) -> RpsController
fn clone(&self) -> RpsController
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for RpsController
impl !RefUnwindSafe for RpsController
impl Send for RpsController
impl Sync for RpsController
impl Unpin for RpsController
impl !UnwindSafe for RpsController
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