module Kudan

Constants

VERSION

Public Class Methods

retryable(tries: 2, sleep_seconds: 1) { |retries, retry_exception| ... } click to toggle source
# File lib/kudan.rb, line 5
def retryable(tries: 2, sleep_seconds: 1)
  retries = 0
  retry_exception = nil

  begin
    yield retries, retry_exception
  rescue StandardError => exception
    raise if retries + 1 > tries

    sleep(sleep_seconds)
    retries += 1
    retry_exception = exception
    retry
  end
end