Module: VmShepherd::RetryHelper

Included in:
AwsManager, OpenstackManager
Defined in:
lib/vm_shepherd/retry_helper.rb

Defined Under Namespace

Classes: RetryLimitExceeded

Constant Summary collapse

RETRY_LIMIT =
10
RETRY_INTERVAL =
60

Instance Method Summary collapse

Instance Method Details

#retry_until(retry_limit: RETRY_LIMIT, retry_interval: RETRY_INTERVAL, &block) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/vm_shepherd/retry_helper.rb', line 9

def retry_until(retry_limit: RETRY_LIMIT, retry_interval: RETRY_INTERVAL, &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