Example #1
0
    def _start(self, term, **global_opt_args):
        token = self.next_token
        self.next_token += 1

        # Construct query
        query = p.Query()
        query.type = p.Query.START
        query.token = token

        # Set global opt args

        # The 'db' option will default to this connection's default
        # if not otherwise specified.
        if 'db' in global_opt_args:
            global_opt_args['db'] = DB(global_opt_args['db'])
        else:
            if self.db:
                global_opt_args['db'] = DB(self.db)

        for k, v in global_opt_args.items():
            pair = query.global_optargs.add()
            pair.key = k
            expr(v).build(pair.val)

        # Compile query to protobuf
        term.build(query.query)
        return self._send_query(query, term, global_opt_args)
Example #2
0
    def _async_continue_cursor(self, cursor):
        self.cursor_cache[cursor.query.token].outstanding_requests += 1

        query = p.Query()
        query.type = p.Query.CONTINUE
        query.token = cursor.query.token
        self._send_query(query, cursor.term, cursor.opts, async=True)
Example #3
0
    def _end_cursor(self, cursor):
        self.cursor_cache[cursor.query.token].outstanding_requests += 1

        query = p.Query()
        query.type = p.Query.STOP
        query.token = cursor.query.token
        self._send_query(cursor.query, cursor.term, async=True)
        self._handle_cursor_response(self._read_response(cursor.query.token))
Example #4
0
    def noreply_wait(self):
        token = self.next_token
        self.next_token += 1

        # Construct query
        query = p.Query()
        query.type = p.Query.NOREPLY_WAIT
        query.token = token

        # Send the request
        return self._send_query(query, 'noreply_wait')