Send "insert" etc. command, returning response as a dict.

        Can raise ConnectionFailure or OperationFailure.

        :Parameters:
          - `request_id`: an int.
          - `msg`: bytes, the command message.
804
def write_command(self, request_id, msg):
        
        self.send_message(msg, 0)
        reply = self.receive_message(request_id)
        result = reply.command_response()

        # Raises NotMasterError or OperationFailure.
        helpers._check_command_response(result)
        return result
135872
def send_message(self, id_service, content):
        """"""
        if not content:
            return
        with self._lock:
            try:
                message = "Message: %s to %s" % (content, id_service)
                self.write_message(message)
                self.stream.flush()  # flush after each message
                return "message_id"
            except Exception:
                if not self.fail_silently:
                    raise
1102401
def merge_request(self, request_id):
        
        request_url = "{}pull-request/{}/merge".format(self.create_basic_url(),
                                                       request_id)

        return_value = self._call_api(request_url, method='POST')

        LOG.debug(return_value)
471194
def request(self, type, command_list):
        '''
        
        '''
        req = self._build_request(type, command_list)
        if self.nxargs['connect_over_uds']:
            self.connection.request('POST', req['url'], req['payload'], req['headers'])
            response = self.connection.getresponse()
        else:
            response = self.connection(req['url'],
                                       method='POST',
                                       opts=req['opts'],
                                       data=req['payload'],
                                       header_dict=req['headers'],
                                       decode=True,
                                       decode_type='json',
                                       **self.nxargs)

        return self.parse_response(response, command_list)
1201333
async def send_script(self, conn_id, data):
        

        self._ensure_connection(conn_id, True)
        connection_string = self._get_property(conn_id, "connection_string")

        msg = dict(connection_string=connection_string, fragment_count=1, fragment_index=0,
                   script=base64.b64encode(data))
        await self._send_command(OPERATIONS.SEND_SCRIPT, msg, COMMANDS.SendScriptResponse)
378919
def check_id(self):
        
        if self.response_id != self.command.get_command_id():
            raise Exception(
                "Error decoding response : the response id {} doesn't match the command id {}".format(self.response_id,
                                                                                                      self.command.get_command_id()))
739017
async def request(self, request):
        
        assert request.transaction_id not in self.transactions

        if self.integrity_key:
            self.__add_authentication(request)

        transaction = stun.Transaction(request, self.server, self)
        self.transactions[request.transaction_id] = transaction
        try:
            return await transaction.run()
        finally:
            del self.transactions[request.transaction_id]
359825
async def connect(self, conn_id, connection_string):
        

        self._ensure_connection(conn_id, False)

        msg = dict(connection_string=connection_string)
        await self._send_command(OPERATIONS.CONNECT, msg, COMMANDS.ConnectResponse)

        self._setup_connection(conn_id, connection_string)
1157250
private void sendCommandToAll(ReplicableCommand command, long requestId, DeliverOrder deliverOrder, boolean rsvp) {
      Message message = new Message();
      marshallRequest(message, command, requestId);
      setMessageFlags(message, deliverOrder, rsvp, true);

      if (deliverOrder == DeliverOrder.TOTAL) {
         message.dest(new AnycastAddress());
      }

      send(message);
   }
419180
private void doFail(long id) {
    if (log.isDebugEnabled()) {
      log.debug(String.format("%s - Received resend request for messages starting at %d", this, id));
    }

    // Ack all the entries before the given ID.
    doAck(id);

    // Now that all the entries before the given ID have been removed,
    // just iterate over the messages map and resend all the messages.
    Iterator<Map.Entry<Long, JsonObject>> iter = messages.entrySet().iterator();
    while (iter.hasNext()) {
      eventBus.send(inAddress, iter.next().getValue());
    }
  }
684942
async def request(self, request, addr, integrity_key=None, retransmissions=None):
        
        assert request.transaction_id not in self.transactions

        if integrity_key is not None:
            request.add_message_integrity(integrity_key)
            request.add_fingerprint()

        transaction = stun.Transaction(request, addr, self, retransmissions=retransmissions)
        transaction.integrity_key = integrity_key
        self.transactions[request.transaction_id] = transaction
        try:
            return await transaction.run()
        finally:
            del self.transactions[request.transaction_id]
1012749
def sendCommand(self, **msg):
		
		assert 'type' in msg, 'Message type is required.'

		msg['id'] = self.next_message_id
		self.next_message_id += 1

		if self.next_message_id >= maxint:
			self.next_message_id = 1

		self.sendMessage(json.dumps(msg))
		return msg['id']
946283
def send_request(self, msg):
        
        assert(msg.mtype == Message.REQUEST)
        if msg.mid and not self._server_supports_ids:
            raise KatcpVersionError('Message IDs not supported by server')
        self.send_message(msg)
356557
function (command, id) {
        id = id || '';
        if (id) {
          this.queue.push(id);
        }
        SocketService.emit('execute', {
          command: command,
          id: id
        });
      }
944381
def _fail(self, request_id, failure, duration):
        """"""
        self.listeners.publish_command_failure(
            duration, failure, self.name,
            request_id, self.sock_info.address, self.op_id)
589582
def batch_message(cls, batch, request_ids):
        ''''''
        assert isinstance(batch, Batch)
        if not cls.allow_batches:
            raise ProtocolError.invalid_request(
                'protocol does not permit batches')
        id_iter = iter(request_ids)
        rm = cls.request_message
        nm = cls.notification_message
        parts = (rm(request, next(id_iter)) if isinstance(request, Request)
                 else nm(request) for request in batch)
        return cls.batch_message_from_parts(parts)
1320132
def _request(self, resource, rtype, action=None, payload=None, offset=None, limit=None, requestId=None,
                 is_crud=False):
        
        end = self.__end
        if end.is_set():
            raise LinkShutdownException('Client stopped')

        rng = None
        if offset is not None and limit is not None:
            Validation.limit_offset_check(limit, offset)
            rng = "%d/%d" % (offset, limit)
        with self.__requests:
            if requestId is None:
                requestId = self.__new_request_id()
            elif requestId in self.__requests:
                raise ValueError('requestId %s already in use' % requestId)
            inner_msg = self.__make_innermsg(resource, rtype, requestId, action, payload, rng)
            self.__requests[requestId] = ret = RequestEvent(requestId, inner_msg, is_crud=is_crud)
        #
        if not self.__retry_enqueue(PreparedMessage(inner_msg, requestId)):
            raise LinkShutdownException('Client stopping')
        return ret