Sha256: d65e35e6f8cd9f42c34eae0ddabaa539e2a3d5da959ab9b67f42464cce9f49b3

Contents?: true

Size: 486 Bytes

Versions: 12

Compression:

Stored size: 486 Bytes

Contents

module VmShepherd
  module RetryHelper
    class RetryLimitExceeded < StandardError
    end

    RETRY_LIMIT = 10
    RETRY_INTERVAL = 60

    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.11.0 lib/vm_shepherd/retry_helper.rb
vm_shepherd-1.10.1 lib/vm_shepherd/retry_helper.rb
vm_shepherd-1.10.0 lib/vm_shepherd/retry_helper.rb
vm_shepherd-1.9.1 lib/vm_shepherd/retry_helper.rb
vm_shepherd-1.9.0 lib/vm_shepherd/retry_helper.rb
vm_shepherd-1.8.4 lib/vm_shepherd/retry_helper.rb
vm_shepherd-1.8.3 lib/vm_shepherd/retry_helper.rb
vm_shepherd-1.8.2 lib/vm_shepherd/retry_helper.rb
vm_shepherd-1.8.1 lib/vm_shepherd/retry_helper.rb
vm_shepherd-1.8.0 lib/vm_shepherd/retry_helper.rb
vm_shepherd-1.7.3 lib/vm_shepherd/retry_helper.rb
vm_shepherd-1.7.2 lib/vm_shepherd/retry_helper.rb