Sha256: a6d8c0ee13f1c5440c9918e2fcfc9a94d2c093d136e11970efb7388bf3a3ab42

Contents?: true

Size: 964 Bytes

Versions: 2

Compression:

Stored size: 964 Bytes

Contents

# frozen_string_literal: true

module Backup
  module CloudIO
    class Error < Backup::Error; end
    class FileSizeError < Backup::Error; end

    class Base
      attr_reader :max_retries, :retry_waitsec

      def initialize(options = {})
        @max_retries    = options[:max_retries]
        @retry_waitsec  = options[:retry_waitsec]
      end

      private

      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
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
backupii-0.1.0.pre.alpha.2 lib/backup/cloud_io/base.rb
backupii-0.1.0.pre.alpha.1 lib/backup/cloud_io/base.rb