Module: Bard::CI::Retryable
Constant Summary collapse
- MAX_RETRIES =
5- INITIAL_DELAY =
1
Instance Method Summary collapse
Instance Method Details
#retry_with_backoff(max_retries: MAX_RETRIES) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/bard/ci/retryable.rb', line 7 def retry_with_backoff(max_retries: MAX_RETRIES) retries = 0 delay = INITIAL_DELAY begin yield rescue => e if retries < max_retries retries += 1 puts " Network error (attempt #{retries}/#{max_retries}): #{e.}. Retrying in #{delay}s..." sleep(delay) delay *= 2 retry else raise "Network error after #{max_retries} attempts: #{e.}" end end end |