1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Merge pull request #408 from cmeiklejohn/expose_default_timeout_value

Move the timeout to Mock and stop hardcoding.
This commit is contained in:
Wesley Beary 2011-07-11 15:25:05 -07:00
commit b3744d8940
4 changed files with 17 additions and 3 deletions

View file

@ -31,4 +31,5 @@ require 'fog/core/service'
require 'fog/core/ssh'
require 'fog/core/scp'
require 'fog/core/time'
require 'fog/core/timeout'
require 'fog/core/wait_for'

View file

@ -42,7 +42,7 @@ module Fog
attributes.to_json
end
def wait_for(timeout=600, interval=1, &block)
def wait_for(timeout=Fog.timeout, interval=1, &block)
reload
retries = 3
Fog.wait_for(timeout, interval) do

13
lib/fog/core/timeout.rb Normal file
View file

@ -0,0 +1,13 @@
module Fog
@timeout = 600
def self.timeout
@timeout
end
def self.timeout=(new_timeout)
raise ArgumentError, "timeout must be non-negative" unless new_timeout >= 0
@timeout = new_timeout
end
end

View file

@ -1,6 +1,6 @@
module Fog
def self.wait_for(timeout=600, interval=1, &block)
def self.wait_for(timeout=Fog.timeout, interval=1, &block)
duration = 0
start = Time.now
until yield || duration > timeout
@ -14,4 +14,4 @@ module Fog
end
end
end
end