Sha256: d1b189590729092756d4d0e68715431843b67f1d65c8cecaa5701f2804c0b9f2

Contents?: true

Size: 488 Bytes

Versions: 3

Compression:

Stored size: 488 Bytes

Contents

module Fog
  def self.wait_for(timeout = Fog.timeout, interval = Fog.interval, &_block)
    duration = 0
    start = Time.now
    retries = 0
    loop do
      break if yield
      if duration > timeout
        raise Errors::TimeoutError, "The specified wait_for timeout (#{timeout} seconds) was exceeded"
      end

      sleep(interval.respond_to?(:call) ? interval.call(retries += 1).to_f : interval.to_f)
      duration = Time.now - start
    end
    { duration: duration }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fog-core-2.6.0 lib/fog/core/wait_for.rb
fog-core-2.5.0 lib/fog/core/wait_for.rb
fog-core-2.4.0 lib/fog/core/wait_for.rb