From 305c1a575a4e988a48c5dbdfdbbd4c7366817c6e Mon Sep 17 00:00:00 2001 From: fzyzcjy <5236035+fzyzcjy@users.noreply.github.com> Date: Sat, 17 Jan 2026 11:58:43 +0800 Subject: [PATCH] Tiny remove unused code (#17047) --- sgl-model-gateway/src/core/retry.rs | 76 ----------------------------- 1 file changed, 76 deletions(-) diff --git a/sgl-model-gateway/src/core/retry.rs b/sgl-model-gateway/src/core/retry.rs index 66b4338fc..3ac0909bb 100644 --- a/sgl-model-gateway/src/core/retry.rs +++ b/sgl-model-gateway/src/core/retry.rs @@ -55,34 +55,6 @@ pub enum RetryError { pub struct RetryExecutor; impl RetryExecutor { - /// Execute an async operation with retries and backoff. - /// The `operation` closure is invoked each attempt with the attempt index. - pub async fn execute_with_retry( - config: &RetryConfig, - mut operation: F, - ) -> Result - where - F: FnMut(u32) -> Fut, - Fut: std::future::Future>, - { - let max = config.max_retries.max(1); - let mut attempt: u32 = 0; - loop { - match operation(attempt).await { - Ok(val) => return Ok(val), - Err(_) => { - let is_last = attempt + 1 >= max; - if is_last { - return Err(RetryError::MaxRetriesExceeded); - } - let delay = BackoffCalculator::calculate_delay(config, attempt); - attempt += 1; - tokio::time::sleep(delay).await; - } - } - } - } - /// Execute an operation that returns an HTTP Response with retries and backoff. /// /// Usage pattern: @@ -220,54 +192,6 @@ mod tests { } } - #[tokio::test] - async fn test_execute_with_retry_success_after_failures() { - let cfg = base_retry_config(); - let remaining = Arc::new(AtomicU32::new(2)); - let calls = Arc::new(AtomicU32::new(0)); - - let res: Result = RetryExecutor::execute_with_retry(&cfg, { - let remaining = remaining.clone(); - let calls = calls.clone(); - move |_attempt| { - calls.fetch_add(1, Ordering::Relaxed); - let remaining = remaining.clone(); - async move { - if remaining - .fetch_update(Ordering::AcqRel, Ordering::Acquire, |v| v.checked_sub(1)) - .is_ok() - { - Err(()) - } else { - Ok(42u32) - } - } - } - }) - .await; - - assert!(res.is_ok()); - assert_eq!(res.unwrap(), 42); - assert_eq!(calls.load(Ordering::Relaxed), 3); - } - - #[tokio::test] - async fn test_execute_with_retry_exhausted() { - let cfg = base_retry_config(); - let calls = Arc::new(AtomicU32::new(0)); - let res: Result = RetryExecutor::execute_with_retry(&cfg, { - let calls = calls.clone(); - move |_attempt| { - calls.fetch_add(1, Ordering::Relaxed); - async move { Err(()) } - } - }) - .await; - - assert!(matches!(res, Err(RetryError::MaxRetriesExceeded))); - assert_eq!(calls.load(Ordering::Relaxed), cfg.max_retries); - } - #[tokio::test] async fn test_execute_response_with_retry_success_path_and_hooks() { let cfg = base_retry_config();