def call(self, ctxt, method, **kwargs): """Invoke a method and wait for a reply. See RPCClient.call().""" if self.target.fanout: raise exceptions.InvalidTarget('A call cannot be used with fanout', self.target) msg = self._make_message(ctxt, method, kwargs) msg_ctxt = self.serializer.serialize_context(ctxt) timeout = self.timeout if self.timeout is None: timeout = self.conf.rpc_response_timeout if self.version_cap: self._check_version_cap(msg.get('version')) try: result = self.transport._send(self.target, msg_ctxt, msg, wait_for_reply=True, timeout=timeout, retry=self.retry) except driver_base.TransportDriverError as ex: raise ClientSendError(self.target, ex) return self.serializer.deserialize_entity(ctxt, result)
def _listen_for_notifications(self, targets_and_priorities): for target, priority in targets_and_priorities: if not target.topic: raise exceptions.InvalidTarget( 'A target must have ' 'topic specified', target) return self._driver.listen_for_notifications(targets_and_priorities)
def _send(self, target, ctxt, message, wait_for_reply=None, timeout=None, retry=None): if not target.topic: raise exceptions.InvalidTarget('A topic is required to send', target) return self._driver.send(target, ctxt, message, wait_for_reply=wait_for_reply, timeout=timeout, retry=retry)
def _send_notification(self, target, ctxt, message, version, retry=None): if not target.topic: raise exceptions.InvalidTarget('A topic is required to send', target) self._driver.send_notification(target, ctxt, message, version, retry=retry)
def _listen(self, target): if not (target.topic and target.server): raise exceptions.InvalidTarget( 'A server\'s target must have ' 'topic and server names specified', target) return self._driver.listen(target)