class Backup::CloudIO::Base

Attributes

max_retries[R]
retry_waitsec[R]

Public Class Methods

new(options = {}) click to toggle source
# File lib/backup/cloud_io/base.rb, line 9
def initialize(options = {})
  @max_retries    = options[:max_retries]
  @retry_waitsec  = options[:retry_waitsec]
end

Private Instance Methods

with_retries(operation) { || ... } click to toggle source
# File lib/backup/cloud_io/base.rb, line 16
      def with_retries(operation)
        retries = 0
        begin
          yield
        rescue => err
          retries += 1
          raise Error.wrap(err, <<-EOS) if retries > max_retries
            Max Retries (#{max_retries}) Exceeded!
            Operation: #{operation}
            Be sure to check the log messages for each retry attempt.
          EOS

          Logger.info Error.wrap(err, <<-EOS)
            Retry ##{retries} of #{max_retries}
            Operation: #{operation}
          EOS
          sleep(retry_waitsec)
          retry
        end
      end