pub struct RetryConfig {
pub max_retries: u32,
pub strategy_type: RetryStrategyType,
pub base_delay_ms: u64,
pub max_delay_ms: u64,
pub retry_on_network_error: bool,
pub retry_on_rate_limit: bool,
pub retry_on_server_error: bool,
pub retry_on_timeout: bool,
pub jitter_factor: f64,
}Expand description
Retry configuration.
Fields§
§max_retries: u32Maximum number of retry attempts.
strategy_type: RetryStrategyTypeType of retry strategy to use.
base_delay_ms: u64Base delay in milliseconds.
max_delay_ms: u64Maximum delay in milliseconds to prevent excessive backoff.
retry_on_network_error: boolWhether to retry on network errors.
retry_on_rate_limit: boolWhether to retry on rate limit errors.
retry_on_server_error: boolWhether to retry on server errors (5xx).
retry_on_timeout: boolWhether to retry on timeout errors.
jitter_factor: f64Jitter factor (0.0-1.0) to add randomness and prevent thundering herd.
Implementations§
Source§impl RetryConfig
impl RetryConfig
Sourcepub fn conservative() -> RetryConfig
pub fn conservative() -> RetryConfig
Creates a conservative retry configuration with fewer retries and shorter delays.
Sourcepub fn aggressive() -> RetryConfig
pub fn aggressive() -> RetryConfig
Creates an aggressive retry configuration with more retries and longer delays.
Sourcepub fn rate_limit_only() -> RetryConfig
pub fn rate_limit_only() -> RetryConfig
Creates a retry configuration for rate limit errors only.
Sourcepub fn validate(&self) -> Result<ValidationResult, ConfigValidationError>
pub fn validate(&self) -> Result<ValidationResult, ConfigValidationError>
Validates the retry configuration parameters.
§Returns
Returns Ok(ValidationResult) if the configuration is valid.
The ValidationResult may contain warnings for suboptimal but valid configurations.
Returns Err(ConfigValidationError) if the configuration is invalid.
§Validation Rules
max_retriesmust be <= 10 (excessive retries can cause issues)base_delay_msmust be >= 10 (too short delays can cause thundering herd)
§Example
use ccxt_core::retry_strategy::RetryConfig;
let config = RetryConfig::default();
let result = config.validate();
assert!(result.is_ok());
let invalid_config = RetryConfig {
max_retries: 15, // Too high
..Default::default()
};
let result = invalid_config.validate();
assert!(result.is_err());Trait Implementations§
Source§impl Clone for RetryConfig
impl Clone for RetryConfig
Source§fn clone(&self) -> RetryConfig
fn clone(&self) -> RetryConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more