Extract exponential backoff logic from await/recover into shared helper
Severity: MEDIUM (Maintainability)
Location
lib/baza-rb.rb:627-629 and 651-653:
seconds = @pause * (2**attempt)
sleep(seconds) unless ENV['RACK_ENV'] == 'test'
Duplicated in await and recover. Similar hardcoded logic in download (sleep(2)).
Problem
Backoff logic is scattered across three methods with slight variations:
await and recover: @pause * (2**attempt) with ENV guard
download: sleep(2) — hardcoded, no exponential backoff
Changing backoff policy requires editing 3+ places.
Recommended fix
def backoff(attempt)
seconds = @pause * (2**attempt)
@loog.info("Sleeping for #{seconds}s (attempt no.#{attempt})...")
sleep(seconds) unless ENV['RACK_ENV'] == 'test'
seconds
end
Use in await, recover, and (with different params) in download.
Related
Extract exponential backoff logic from await/recover into shared helper
Severity: MEDIUM (Maintainability)
Location
lib/baza-rb.rb:627-629and651-653:Duplicated in
awaitandrecover. Similar hardcoded logic indownload(sleep(2)).Problem
Backoff logic is scattered across three methods with slight variations:
awaitandrecover:@pause * (2**attempt)with ENV guarddownload:sleep(2)— hardcoded, no exponential backoffChanging backoff policy requires editing 3+ places.
Recommended fix
Use in
await,recover, and (with different params) indownload.Related