lib/ddbcli/ddb-client.rb
def retry_query
      retval = nil

      (@retry_num + 1).times do |i|
        begin
          retval = yield
          break
        rescue Errno::ETIMEDOUT => e
          raise e if i >= @retry_num
        rescue DynamoDB::Error => e
          if [/\bServiceUnavailable\b/i, /\bexceeded\b/i].any? {|i| i =~ e.message }
            raise e if i >= @retry_num
          else
            raise e
          end
        rescue Timeout::Error => e
          raise e if i >= @retry_num
        end

        wait_sec = @retry_intvl * (i + 1)

        if @debug
          $stderr.puts("Retry... (wait %d seconds)" % wait_sec)
        end

        sleep wait_sec
      end

      return retval
    end
def retry_query
      retval = nil

      (@retry_num + 1).times do |i|
        begin
          retval = yield
          break
        rescue Errno::ETIMEDOUT => e
          raise e if i >= @retry_num
        rescue DynamoDB::Error => e
          if [/\bServiceUnavailable\b/i, /\bexceeded\b/i].any? {|i| i =~ e.message }
            raise e if i >= @retry_num
          else
            raise e
          end
        rescue Timeout::Error => e
          raise e if i >= @retry_num
        end

        wait_sec = @retry_intvl * (i + 1)

        if @debug
          $stderr.puts("Retry... (wait %d seconds)" % wait_sec)
        end

        sleep wait_sec
      end

      return retval
    end
def retry_query retval = nil ( @retry_num + 1 ) . times do | i | begin retval = yield break rescue Errno :: ETIMEDOUT => e raise e if i >= @retry_num rescue DynamoDB :: Error => e if [ / \b \b /i , / \b \b /i ] . any? { | i | i =~ e . message } raise e if i >= @retry_num else raise e end rescue Timeout :: Error => e raise e if i >= @retry_num end wait_sec = @retry_intvl * ( i + 1 ) if @debug $stderr . puts ( "Retry... (wait %d seconds)" % wait_sec ) end sleep wait_sec end return retval end
def escape(str)
  CGI.escape(str.to_s).gsub('+', '%20')
end
def escape ( str ) CGI . escape ( str . to_s ) . gsub ( + %20 ) end