pub struct ThrottlePolicy {
pub base_delay_ms: u64,
pub adaptive_jitter_ms: u64,
pub max_concurrent: usize,
pub max_retries: usize,
}Expand description
Defines the throttling and backoff behavior for handling HTTP requests.
This policy determines the rate limiting strategy used for outgoing requests, including fixed delays, adaptive backoff, and retry settings.
Fields§
§base_delay_ms: u64The base delay (in milliseconds) applied before making a request.
This ensures a minimum delay between consecutive requests.
adaptive_jitter_ms: u64The maximum random jitter (in milliseconds) added to the backoff delay.
This prevents synchronization issues when multiple clients are making requests, reducing the likelihood of rate-limit collisions.
max_concurrent: usizeThe maximum number of concurrent requests allowed at any given time.
This controls parallel request execution, ensuring that no more than
max_concurrent requests are in-flight simultaneously.
max_retries: usizeThe maximum number of retries allowed in case of failed requests.
If a request fails (e.g., due to a server error or rate limiting),
it will be retried up to max_retries times with exponential backoff.
Trait Implementations§
Source§impl Clone for ThrottlePolicy
impl Clone for ThrottlePolicy
Source§fn clone(&self) -> ThrottlePolicy
fn clone(&self) -> ThrottlePolicy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ThrottlePolicy
impl Debug for ThrottlePolicy
Source§impl Default for ThrottlePolicy
impl Default for ThrottlePolicy
Source§fn default() -> Self
fn default() -> Self
Provides a sensible default throttling policy.
This default configuration is suitable for most API use cases and includes:
- A base delay of 500ms between requests.
- A random jitter of up to 250ms to avoid synchronization issues.
- A maximum of 5 concurrent requests to prevent excessive load.
- A maximum of 3 retries for failed requests.
§Returns
A ThrottlePolicy instance with preconfigured defaults.