def __init__(self, conf, matchmaker=None, allowed_remote_exmods=None): default_publisher = zmq_dealer_publisher.DealerPublisher( conf, matchmaker) if not conf.direct_over_proxy else \ zmq_dealer_publisher.DealerPublisherLight( conf, zmq_address.get_broker_address(conf)) fanout_publisher = zmq_dealer_publisher.DealerPublisherLight( conf, zmq_address.get_broker_address(conf)) \ if conf.use_pub_sub else default_publisher super(ZmqClient, self).__init__( conf, matchmaker, allowed_remote_exmods, publishers={ zmq_names.CALL_TYPE: zmq_dealer_call_publisher.DealerCallPublisher( conf, matchmaker), # Here use DealerPublisherLight for sending request to proxy # which finally uses PubPublisher to send fanout in case of # 'use_pub_sub' option configured. zmq_names.CAST_FANOUT_TYPE: fanout_publisher, zmq_names.NOTIFY_TYPE: fanout_publisher, "default": default_publisher })
def __init__(self, conf, matchmaker=None, allowed_remote_exmods=None): default_publisher = ( zmq_dealer_publisher.DealerPublisher(conf, matchmaker) if not conf.direct_over_proxy else zmq_dealer_publisher.DealerPublisherLight(conf, zmq_address.get_broker_address(conf)) ) super(ZmqClient, self).__init__( conf, matchmaker, allowed_remote_exmods, publishers={ zmq_names.CALL_TYPE: zmq_dealer_call_publisher.DealerCallPublisher(conf, matchmaker), # Here use DealerPublisherLight for sending request to proxy # which finally uses PubPublisher to send fanout in case of # 'use_pub_sub' option configured. zmq_names.CAST_FANOUT_TYPE: zmq_dealer_publisher.DealerPublisherLight( conf, zmq_address.get_broker_address(conf) ) if conf.use_pub_sub else default_publisher, "default": default_publisher, }, )
def _check_hosts_connections(self, target, listener_type): if self.socket is None: self.socket = zmq_socket.ZmqSocket(self.zmq_context, self.socket_type) self.outbound_sockets[str(target)] = self.socket address = zmq_address.get_broker_address(self.conf) self._connect_to_address(self.socket, address, target) return self.socket
def get_socket_to_broker(self, target): socket = zmq_socket.ZmqSocket(self.conf, self.zmq_context, self.socket_type) self._track_socket(socket, target) address = zmq_address.get_broker_address(self.conf) socket.connect_to_address(address) return socket
def __init__(self, conf, context, queue): super(IncomingQueueProxy, self).__init__(conf, context) self.poller = zmq_async.get_poller( zmq_concurrency='native') self.queue = queue self.socket = context.socket(zmq.ROUTER) self.socket.bind(zmq_address.get_broker_address(conf)) self.poller.register(self.socket, self.receive_request) LOG.info(_LI("Polling at incoming proxy ..."))
def __init__(self, conf, context, matchmaker): super(UniversalQueueProxy, self).__init__(conf, context) self.poller = zmq_async.get_poller(zmq_concurrency='native') self.router_socket = context.socket(zmq.ROUTER) self.router_socket.bind(zmq_address.get_broker_address(conf)) self.poller.register(self.router_socket, self._receive_in_request) LOG.info(_LI("Polling at universal proxy")) self.matchmaker = matchmaker self.pub_publisher = zmq_pub_publisher.PubPublisherProxy( conf, matchmaker)
def __init__(self, conf, matchmaker=None, allowed_remote_exmods=None): self.conf = conf self.context = zmq.Context() self.matchmaker = matchmaker self.allowed_remote_exmods = allowed_remote_exmods or [] self.dealer_publisher = None if self.conf.zmq_use_broker: self.dealer_publisher = zmq_dealer_publisher.DealerPublisherLight( conf, zmq_address.get_broker_address(self.conf)) else: self.dealer_publisher = zmq_dealer_publisher.DealerPublisher( conf, matchmaker)
def _do_send_request(socket, request): if request.msg_type == zmq_names.CALL_TYPE: raise zmq_publisher_base.UnsupportedSendPattern( request.msg_type) envelope = request.create_envelope() socket.send(b'', zmq.SNDMORE) socket.send_pyobj(envelope, zmq.SNDMORE) socket.send_pyobj(request) LOG.debug("->[proxy:%(addr)s] Sending message_id %(message)s to " "a target %(target)s", {"message": request.message_id, "target": request.target, "addr": zmq_address.get_broker_address(conf)})
def __init__(self, conf, matchmaker=None, allowed_remote_exmods=None): if not conf.zmq_use_broker: raise rpc_common.RPCException( "This client needs proxy to be configured!") super(ZmqClientLight, self).__init__( conf, matchmaker, allowed_remote_exmods, publishers={ zmq_names.CALL_TYPE: zmq_dealer_call_publisher.DealerCallPublisher( conf, matchmaker), "default": zmq_dealer_publisher.DealerPublisherLight( conf, zmq_address.get_broker_address(self.conf)) } )
def _do_send_request(socket, request): if request.msg_type == zmq_names.CALL_TYPE: raise zmq_publisher_base.UnsupportedSendPattern( request.msg_type) envelope = request.create_envelope() socket.send(b'', zmq.SNDMORE) socket.send_pyobj(envelope, zmq.SNDMORE) socket.send_pyobj(request) LOG.debug( "->[proxy:%(addr)s] Sending message_id %(message)s to " "a target %(target)s", { "message": request.message_id, "target": request.target, "addr": zmq_address.get_broker_address(conf) })
def get_socket_to_broker(self): socket = zmq_socket.ZmqSocket(self.conf, self.zmq_context, self.socket_type) address = zmq_address.get_broker_address(self.conf) socket.connect_to_address(address) return socket
def _resolve_host_address(self, target, timeout=0): return zmq_address.get_broker_address(self.conf)