Sha256: 29b61007971a466db742aeb94cf912f4f598d387761556e2fe69c1b4ef51c9f9

Contents?: true

Size: 486 Bytes

Versions: 3

Compression:

Stored size: 486 Bytes

Contents

module VmShepherd
  module RetryHelper
    class RetryLimitExceeded < StandardError
    end

    RETRY_LIMIT = 60
    RETRY_INTERVAL = 10

    def retry_until(retry_limit: RETRY_LIMIT, &block)
      tries = 0
      condition_reached = false
      loop do
        tries += 1
        raise(RetryLimitExceeded) if tries > retry_limit
        condition_reached = block.call
        break if condition_reached
        sleep RETRY_INTERVAL
      end
      condition_reached
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vm_shepherd-1.7.1 lib/vm_shepherd/retry_helper.rb
vm_shepherd-1.7.0 lib/vm_shepherd/retry_helper.rb
vm_shepherd-1.6.1 lib/vm_shepherd/retry_helper.rb