예제 #1
0
func (c *Cursor) extend(response *p.Response) {
	c.mu.Lock()
	c.finished = response.GetType() != p.Response_SUCCESS_PARTIAL &&
		response.GetType() != p.Response_SUCCESS_FEED
	c.responses = append(c.responses, response)

	// Prefetch results if needed
	if len(c.responses) == 1 && !c.finished {
		if err := c.session.asyncContinueQuery(c); err != nil {
			c.err = err
			return
		}
	}

	// Load the new response into the buffer
	var err error
	c.buffer, err = deconstructDatums(c.responses[0].GetResponse(), c.opts)
	if err != nil {
		c.err = err

		return
	}
	c.responses = c.responses[1:]
	c.mu.Unlock()
}
예제 #2
0
func checkErrorResponse(response *p.Response, t Term) error {
	switch response.GetType() {
	case p.Response_CLIENT_ERROR:
		return RqlClientError{rqlResponseError{response, t}}
	case p.Response_COMPILE_ERROR:
		return RqlCompileError{rqlResponseError{response, t}}
	case p.Response_RUNTIME_ERROR:
		return RqlRuntimeError{rqlResponseError{response, t}}
	}

	return nil
}
예제 #3
0
func (s *Session) handleBatchResponse(cursor *Cursor, response *p.Response) {
	cursor.extend(response)

	s.Lock()
	cursor.outstandingRequests -= 1

	if response.GetType() != p.Response_SUCCESS_PARTIAL &&
		response.GetType() != p.Response_SUCCESS_FEED &&
		cursor.outstandingRequests == 0 {
		delete(s.cache, response.GetToken())
	}
	s.Unlock()
}