pub trait Algorithm {
// Required methods
fn max_concurrency(&self) -> usize;
fn update(
&mut self,
rtt: Duration,
num_inflight: usize,
is_error: bool,
is_canceled: bool,
);
}Expand description
An algorithm that dynamically adjusts the maximum number of allowed concurrent requests based on the observed traffic.
Required Methods§
Sourcefn max_concurrency(&self) -> usize
fn max_concurrency(&self) -> usize
Returns the maximum number of concurrent requests the algorithm currently allows.
§Panics
Implementations must not panic. This method is called while holding a shared mutex; a panic would poison it and abort on the next request.
Sourcefn update(
&mut self,
rtt: Duration,
num_inflight: usize,
is_error: bool,
is_canceled: bool,
)
fn update( &mut self, rtt: Duration, num_inflight: usize, is_error: bool, is_canceled: bool, )
Observes the outcome of a request and updates the algorithm’s state accordingly.
§Panics
Implementations must not panic. This method is called while holding a shared mutex; a panic would poison it and abort on the next request.