pub struct Paced { /* private fields */ }Expand description
Spaces request starts at least min_interval apart, across all tasks
sharing it, and optionally limits requests in flight. Slots are handed
out in arrival order, so waiting is fair.
With shared pacing, slots come from a store that
every process using it shares (the cache file), so parallel processes
keep to one rate between them; if the store fails, pacing falls back to
this process alone.
Logs each request (at info, target aspero::http) with the provider
label, status, duration and time spent waiting for a slot.
Implementations§
Source§impl Paced
impl Paced
pub fn new( label: impl Into<String>, inner: Arc<dyn HttpClient>, min_interval: Duration, ) -> Self
Sourcepub fn max_in_flight(self, n: usize) -> Self
pub fn max_in_flight(self, n: usize) -> Self
Keeps at most n requests in flight at once (0: no limit), for
providers that refuse concurrent requests rather than fast ones.
Paces with every other process using pacing.
Trait Implementations§
Source§impl HttpClient for Paced
impl HttpClient for Paced
Source§fn send<'life0, 'async_trait>(
&'life0 self,
request: HttpRequest,
) -> Pin<Box<dyn Future<Output = Result<HttpResponse, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn send<'life0, 'async_trait>(
&'life0 self,
request: HttpRequest,
) -> Pin<Box<dyn Future<Output = Result<HttpResponse, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sends one request.
Ok for every HTTP status; Err only for transport
failures (Network, Timeout).Auto Trait Implementations§
impl !Freeze for Paced
impl !RefUnwindSafe for Paced
impl !UnwindSafe for Paced
impl Forget for Paced
impl Move for Paced
impl Send for Paced
impl Sync for Paced
impl Unpin for Paced
impl UnsafeUnpin for Paced
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