Download crates/forge_config/src/retry.rs from SaylorTwift/forgecode: direct link, hf CLI and curl.
- Browser
- Download file 1.5 kB
-
https://huggingface.co/SaylorTwift/forgecode/resolve/main/crates/forge_config/src/retry.rs
- Command line
-
hf download hf://SaylorTwift/forgecode/crates/forge_config/src/retry.rs
-
curl -L -o retry.rs https://huggingface.co/SaylorTwift/forgecode/resolve/main/crates/forge_config/src/retry.rs
1.5 kB
| use derive_setters::Setters; | |
| use schemars::JsonSchema; | |
| use serde::{Deserialize, Serialize}; | |
| /// Configuration for retry mechanism. | |
| pub struct RetryConfig { | |
| /// Initial backoff delay in milliseconds for retry operations | |
| pub initial_backoff_ms: u64, | |
| /// Minimum delay in milliseconds between retry attempts | |
| pub min_delay_ms: u64, | |
| /// Backoff multiplication factor for each retry attempt | |
| pub backoff_factor: u64, | |
| /// Maximum number of retry attempts | |
| pub max_attempts: usize, | |
| /// HTTP status codes that should trigger retries | |
| pub status_codes: Vec<u16>, | |
| /// Maximum delay between retries in seconds | |
| pub max_delay_secs: Option<u64>, | |
| /// Whether to suppress retry error logging and events | |
| pub suppress_errors: bool, | |
| } | |
| mod tests { | |
| use pretty_assertions::assert_eq; | |
| use super::*; | |
| fn test_retry_config_fields() { | |
| let config = RetryConfig { | |
| initial_backoff_ms: 200, | |
| min_delay_ms: 1000, | |
| backoff_factor: 2, | |
| max_attempts: 8, | |
| status_codes: vec![429, 500, 502, 503, 504, 408, 522, 524, 520, 529], | |
| max_delay_secs: None, | |
| suppress_errors: false, | |
| }; | |
| assert_eq!(config.initial_backoff_ms, 200); | |
| assert_eq!(config.suppress_errors, false); | |
| } | |
| } | |