Module: NexusSW::LXD

Defined in:
lib/nexussw/lxd.rb,
lib/nexussw/lxd/driver.rb,
lib/nexussw/lxd/version.rb,
lib/nexussw/lxd/transport.rb,
lib/nexussw/lxd/driver/cli.rb,
lib/nexussw/lxd/driver/rest.rb,
lib/nexussw/lxd/transport/cli.rb,
lib/nexussw/lxd/transport/rest.rb,
lib/nexussw/lxd/transport/local.rb,
lib/nexussw/lxd/driver/mixins/cli.rb,
lib/nexussw/lxd/driver/mixins/rest.rb,
lib/nexussw/lxd/transport/mixins/cli.rb,
lib/nexussw/lxd/transport/mixins/rest.rb,
lib/nexussw/lxd/transport/mixins/local.rb,
lib/nexussw/lxd/driver/mixins/helpers/wait.rb,
lib/nexussw/lxd/transport/mixins/helpers/execute.rb,
lib/nexussw/lxd/transport/mixins/helpers/upload_folder.rb

Defined Under Namespace

Classes: Driver, Transport

Constant Summary collapse

VERSION =
'0.6.0'.freeze

Class Method Summary collapse

Class Method Details

.with_timeout_and_retries(options = {}) ⇒ Object

Must specify :retry_interval in order to receive retries And if so, then either :timeout or :retry_count must be specified

:timeout == 0 without :retry_count is valid in this case, saying to retry forever

If nothing is specified, then this function is ineffectual and runs indefinitely



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/nexussw/lxd.rb', line 14

def self.with_timeout_and_retries(options = {})
  Timeout.timeout(options[:timeout] || 0) do
    tries = 0
    loop do
      begin
        Timeout.timeout(options[:retry_interval] || 0, Timeout::Retry) do
          tries += 1
          return yield
        end
      rescue Timeout::Retry
        next if options[:retry_count] && (tries <= options[:retry_count])
        next if options[:timeout]
        raise
      end
    end
  end
end