def retry_interval(expires_at, attempts, max_retries = nil)
      if @options[:retry_enabled]
        if max_retries.nil? || attempts <= max_retries
          interval = @options[:retry_intervals][attempts - 1] || @options[:retry_intervals][-1]
          ((Time.now + interval) < expires_at) ? interval : 0
        else
          0
        end
      end
    end
def retry_interval(expires_at, attempts, max_retries = nil)
      if @options[:retry_enabled]
        if max_retries.nil? || attempts <= max_retries
          interval = @options[:retry_intervals][attempts - 1] || @options[:retry_intervals][-1]
          ((Time.now + interval) < expires_at) ? interval : 0
        else
          0
        end
      end
    end
Determine time interval before next retry

 @param [Time] expires_at time for request
 @param [Integer] attempts so far
 @param [Integer] max_retries

 @return [Integer, NilClass] retry interval with 0 meaning no try and nil meaning retry disabled