def __init__(self, conf, context, matchmaker): self.conf = conf self.context = context super(UniversalQueueProxy, self).__init__() self.matchmaker = matchmaker self.poller = zmq_async.get_poller() port = conf.zmq_proxy_opts.frontend_port host = conf.zmq_proxy_opts.host self.fe_router_socket = zmq_socket.ZmqFixedPortSocket( conf, context, zmq.ROUTER, host, conf.zmq_proxy_opts.frontend_port) if port != 0 else \ zmq_socket.ZmqRandomPortSocket(conf, context, zmq.ROUTER, host) port = conf.zmq_proxy_opts.backend_port self.be_router_socket = zmq_socket.ZmqFixedPortSocket( conf, context, zmq.ROUTER, host, conf.zmq_proxy_opts.backend_port) if port != 0 else \ zmq_socket.ZmqRandomPortSocket(conf, context, zmq.ROUTER, host) self.poller.register(self.fe_router_socket.handle, self._receive_in_request) self.poller.register(self.be_router_socket.handle, self._receive_in_request) self.pub_publisher = zmq_publisher_proxy.PublisherProxy( conf, matchmaker) self._router_updater = RouterUpdater( conf, matchmaker, self.pub_publisher.host, self.fe_router_socket.connect_address, self.be_router_socket.connect_address)
def __init__(self, conf, context, matchmaker): self.conf = conf self.context = context super(UniversalQueueProxy, self).__init__() self.matchmaker = matchmaker self.poller = zmq_async.get_poller() self.fe_router_socket = zmq_socket.ZmqRandomPortSocket( conf, context, zmq.ROUTER) self.be_router_socket = zmq_socket.ZmqRandomPortSocket( conf, context, zmq.ROUTER) self.poller.register(self.fe_router_socket.handle, self._receive_in_request) self.poller.register(self.be_router_socket.handle, self._receive_in_request) self.fe_router_address = zmq_address.combine_address( self.conf.rpc_zmq_host, self.fe_router_socket.port) self.be_router_address = zmq_address.combine_address( self.conf.rpc_zmq_host, self.be_router_socket.port) self.pub_publisher = zmq_pub_publisher.PubPublisherProxy( conf, matchmaker) self._router_updater = RouterUpdater(conf, matchmaker, self.pub_publisher.host, self.fe_router_address, self.be_router_address)
def __init__(self, conf, matchmaker): super(PubPublisherProxy, self).__init__() self.conf = conf self.zmq_context = zmq.Context() self.matchmaker = matchmaker self.socket = zmq_socket.ZmqRandomPortSocket( self.conf, self.zmq_context, zmq.PUB) self.host = zmq_address.combine_address(self.conf.rpc_zmq_host, self.socket.port)
def __init__(self, conf, context, matchmaker): super(UniversalQueueProxy, self).__init__(conf, context) self.matchmaker = matchmaker self.poller = zmq_async.get_poller(zmq_concurrency='native') self.router_socket = zmq_socket.ZmqRandomPortSocket( conf, context, zmq.ROUTER) self.poller.register(self.router_socket.handle, self._receive_in_request) self.router_address = zmq_address.combine_address( self.conf.rpc_zmq_host, self.router_socket.port)
def __init__(self, conf, matchmaker, context): self.conf = conf self.matchmaker = matchmaker self.context = context self._ready = None # NOTE(ozamiatin): May be used for heartbeats when we # implement them self.sync_socket = zmq_socket.ZmqRandomPortSocket( self.conf, self.context, zmq.PULL) self.poller = zmq_async.get_poller() self.poller.register(self.sync_socket) self.sync_host = zmq_address.combine_address(self.conf.rpc_zmq_host, self.sync_socket.port)
def __init__(self, conf, matchmaker): super(PublisherProxy, self).__init__() self.conf = conf self.zmq_context = zmq.Context() self.matchmaker = matchmaker port = conf.zmq_proxy_opts.publisher_port self.socket = zmq_socket.ZmqFixedPortSocket( self.conf, self.zmq_context, zmq.PUB, conf.zmq_proxy_opts.host, port) if port != 0 else \ zmq_socket.ZmqRandomPortSocket( self.conf, self.zmq_context, zmq.PUB, conf.zmq_proxy_opts.host) self.host = self.socket.connect_address
def create_socket(conf, context, port, socket_type): host = conf.zmq_proxy_opts.host identity = six.b(host) + b"/zmq-proxy/" + six.b(str(uuid.uuid4())) if port != 0: return zmq_socket.ZmqFixedPortSocket(conf, context, socket_type, host, port, identity=identity) else: return zmq_socket.ZmqRandomPortSocket(conf, context, socket_type, host, identity=identity)
def subscribe_socket(self, socket_type): try: socket = zmq_socket.ZmqRandomPortSocket( self.conf, self.context, socket_type) self.sockets.append(socket) self.poller.register(socket, self.receive_message) LOG.info(_LI("Run %(stype)s consumer on %(addr)s:%(port)d"), {"stype": zmq_names.socket_type_str(socket_type), "addr": socket.bind_address, "port": socket.port}) return socket except zmq.ZMQError as e: errmsg = _LE("Failed binding to port %(port)d: %(e)s")\ % (self.port, e) LOG.error(_LE("Failed binding to port %(port)d: %(e)s") % (self.port, e)) raise rpc_common.RPCException(errmsg)
def __init__(self, conf, matchmaker): super(PubPublisherProxy, self).__init__(conf) self.matchmaker = matchmaker self.socket = zmq_socket.ZmqRandomPortSocket(self.conf, self.zmq_context, zmq.PUB) self.host = zmq_address.combine_address(self.conf.rpc_zmq_host, self.socket.port) self.sync_channel = SyncChannel(conf, matchmaker, self.zmq_context) LOG.info(_LI("[PUB:%(pub)s, PULL:%(pull)s] Run PUB publisher"), { "pub": self.host, "pull": self.sync_channel.sync_host }) self.matchmaker.register_publisher( (self.host, self.sync_channel.sync_host))