Module: Elbas::Retryable

Included in:
AWSResource
Defined in:
lib/elbas/retryable.rb

Instance Method Summary collapse

Instance Method Details

#with_retry(max: fetch(:elbas_retry_max, 3), delay: fetch(:elbas_retry_delay, 5)) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/elbas/retryable.rb', line 3

def with_retry(max: fetch(:elbas_retry_max, 3), delay: fetch(:elbas_retry_delay, 5))
  tries ||= 0
  tries += 1
  yield
rescue => e
  p "Rescued #{e.message}"
  if tries < max
    p "Retrying in #{delay} seconds..."
    sleep delay
    retry
  end
end