pub struct Throttle { /* private fields */ }Expand description
Pacing shared by every call through the transports that hold it.
Retries alone slow down only the call that was refused: the others keep sending at full speed
and are refused in turn. A Throttle shared by concurrent calls makes a 429 or 529 on any of
them slow all of them, the way a well-behaved client pool should:
- No call starts before the server’s delay is over. The delay is the
Retry-Afterthe server sent, or else the retry policy’s backoff. - Calls then start one at a time, spaced out. The gap doubles with each refusal, from 100 ms up to 5 s, and shrinks by an eighth with each success until pacing stops: a pool that keeps being refused slows down fast, and one that stops being refused speeds up again gradually.
Without refusals it does nothing. Attach one with
HttpTransport::with_throttle; clones of a transport
share it.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Throttle
impl Forget for Throttle
impl Move for Throttle
impl RefUnwindSafe for Throttle
impl Send for Throttle
impl Sync for Throttle
impl Unpin for Throttle
impl UnsafeUnpin for Throttle
impl UnwindSafe for Throttle
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