Skip to main content

should_retry

Function should_retry 

Source
pub fn should_retry(
    _spec_id: &str,
    retry_state: &RetryState,
    error_log: &str,
    config: &FailureConfig,
) -> Result<RetryDecision>
Expand description

Determine whether a failed spec should be retried based on retry state, error log and config.

§Arguments

  • spec_id - The spec ID (for error messages, currently unused)
  • retry_state - Current retry state with attempt count
  • error_log - The error log content to scan for retryable patterns
  • config - Failure configuration with retry settings and patterns

§Returns

  • Ok(RetryDecision::Retry(delay)) - Should retry after the delay
  • Ok(RetryDecision::PermanentFailure(reason)) - Permanent failure, don’t retry
  • Err(_) - Configuration error

§Edge Cases

  • Empty or missing error log → PermanentFailure
  • max_retries = 0 → First failure is permanent
  • No pattern match → PermanentFailure
  • Backoff overflow → Capped at 1 hour
  • Multiple pattern matches → Still retryable (OR logic)
  • Exceeded max_retries → PermanentFailure