Sha256: 7747f55f3b399dddefc613a7ad348711941d4792a5dd48a0ea760cacbcbc2f24

Contents?: true

Size: 485 Bytes

Versions: 12

Compression:

Stored size: 485 Bytes

Contents

module VmShepherd
  module RetryHelper
    class RetryLimitExceeded < StandardError
    end

    RETRY_LIMIT = 60
    RETRY_INTERVAL = 5

    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

12 entries across 12 versions & 1 rubygems

Version Path
vm_shepherd-1.6.0 lib/vm_shepherd/retry_helper.rb
vm_shepherd-1.5.4 lib/vm_shepherd/retry_helper.rb
vm_shepherd-1.5.3 lib/vm_shepherd/retry_helper.rb
vm_shepherd-1.5.2 lib/vm_shepherd/retry_helper.rb
vm_shepherd-1.5.1 lib/vm_shepherd/retry_helper.rb
vm_shepherd-1.5.0 lib/vm_shepherd/retry_helper.rb
vm_shepherd-1.4.0 lib/vm_shepherd/retry_helper.rb
vm_shepherd-1.3.2 lib/vm_shepherd/retry_helper.rb
vm_shepherd-1.3.1 lib/vm_shepherd/retry_helper.rb
vm_shepherd-1.3.0 lib/vm_shepherd/retry_helper.rb
vm_shepherd-1.2.0 lib/vm_shepherd/retry_helper.rb
vm_shepherd-1.1.1 lib/vm_shepherd/retry_helper.rb