How to use the txzmq.ZmqEndpoint function in txZMQ

To help you get started, we’ve selected a few txZMQ examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mokshaproject / moksha / moksha.hub / moksha / hub / zeromq / zeromq.py View on Github external
# Factory used to lazily produce subsequent subscribers
        self.twisted_zmq_factory = txzmq.ZmqFactory()

        # Establish a list of subscription endpoints for later use
        _endpoints = self.config['zmq_subscribe_endpoints'].split(',')
        method = self.config.get('zmq_subscribe_method', 'connect')

        if method == 'bind':
            _endpoints = sum(map(list, map(hostname2ipaddr, _endpoints)), [])
        else:
            # Required for zeromq-3.x.
            _endpoints = sum(map(list, map(splat2ipaddr, _endpoints)), [])

        self.sub_endpoints = [
            txzmq.ZmqEndpoint(method, ep) for ep in _endpoints
        ]

        # This is required so that the publishing socket can fully set itself
        # up before we start trying to send messages on it.  This is a
        # documented zmq issue that they do not plan to fix.
        time.sleep(1)

        super(ZMQHubExtension, self).__init__()
github PyAr / lalita / lalita / plugins / zmq_proxy.py View on Github external
def init(self, config):
        self._plugins = {}
        self.config = config
        pub_address = self.config['events_address']
        cmd_address = self.config['bot_address']
        self.commands = set() # hold all the commands
        self.ctx = zmq.Context.instance()
        self.pub_socket = self.ctx.socket(zmq.PUB)
        self.pub_socket.bind(pub_address)
        # callback/command socket
        zmq_factory = ZmqFactory(context=self.ctx)
        rpc_endpoint = ZmqEndpoint("bind", cmd_address)
        self.cmd_socket = BotConnection(self, zmq_factory, rpc_endpoint)
        self.cmd_socket.subscribe("")
        for event, info in EVENT_MAP.items():
            if event != events.COMMAND:
                self.register(event, EventHandler(self, *info), re.compile(".*"))
github erikkaplun / spinoff / spinoff / actor / remoting.py View on Github external
def _connect(self, addr, conn):
        assert _valid_addr(addr)
        # dbg("...connecting to %s" % (addr,))
        self.outgoing.addEndpoints([ZmqEndpoint('connect', addr)])
        # send one heartbeat immediately for better latency
        dbg(u"►► ❤ → %s" % (addr,))
        self._heartbeat_once(addr, PING if conn.state == 'radiosilence' else PONG)
github erikkaplun / spinoff / spinoff / actor / zmqdemo / zmqdemo2.py View on Github external
while True:
            print 'CONSUMER %s sending' % self.id
            self.put(message='msg-from-%s' % self.id)
            msg = yield self.get()
            print 'CONSUMER %s received %s' % (self.id, msg)


f = ZmqFactory()

BROKER_BE_ADDR = 'ipc://broker-be'
BROKER_FE_ADDR = 'ipc://broker-fe'


broker = TestBroker()

make_cycle(ZmqRouter(f, ZmqEndpoint('bind', BROKER_FE_ADDR)),
           ('frontend', broker, 'frontend'))

make_cycle(ZmqReq(f, ZmqEndpoint('bind', BROKER_BE_ADDR)),
           ('backend', broker, 'backend'))



consumers = [TestConsumer(i + 1) for i in range(3)]
for consumer in consumers:
    dealer = ZmqDealer(f, BROKER_FE_ADDR)
    make_cycle(consumer, dealer)

producers = [TestProducer(i + 1) for i in range(3)]
for producer in producers:
    rep = ZmqRep(f, ZmqEndpoint('connect', BROKER_BE_ADDR))
    make_cycle(producer, rep)
github jarret / lightning-station / block_listener.py View on Github external
def __init__(self, reactor, screen_ui, audio_player, first_block_hash):
        f = ZmqFactory()
        f.reactor = reactor
        e = ZmqEndpoint("connect", "tcp://127.0.0.1:28332")
        s = ZmqSubConnection(f, e)
        s.subscribe("hashblock".encode("utf-8"))
        s.messageReceived = self.listener
        self.screen_ui = screen_ui
        self.new_block_queue = []
        self.queue_running = False
        self.audio_player = audio_player

        new_block = NewBlock(self, first_block_hash, self.screen_ui,
                             audio_player)
        self.new_block_queue.append(new_block)
        self._try_next()
github gtaylor / dockerized-image-crawler / crawler / crawler_worker / services / zeromq.py View on Github external
def startService(self):
        factory = ZmqFactory()
        log.msg("Delegator connecting to repeater: %s" % ZMQ_REPEATER)
        endpoint = ZmqEndpoint('connect', ZMQ_REPEATER)
        self.conn = ZmqPushConnection(factory, endpoint)
github erikkaplun / spinoff / unnamedframework / actor / zmqdemo / zmqdemo2.py View on Github external
while True:
            print 'CONSUMER %s sending' % self.id
            self.put(message='msg-from-%s' % self.id)
            msg = yield self.get()
            print 'CONSUMER %s received %s' % (self.id, msg)


f = ZmqFactory()

BROKER_BE_ADDR = 'ipc://broker-be'
BROKER_FE_ADDR = 'ipc://broker-fe'


broker = TestBroker()

make_cycle(ZmqRouter(f, ZmqEndpoint('bind', BROKER_FE_ADDR)),
           ('frontend', broker, 'frontend'))

make_cycle(ZmqReq(f, ZmqEndpoint('bind', BROKER_BE_ADDR)),
           ('backend', broker, 'backend'))



consumers = [TestConsumer(i + 1) for i in range(3)]
for consumer in consumers:
    dealer = ZmqDealer(f, BROKER_FE_ADDR)
    make_cycle(consumer, dealer)

producers = [TestProducer(i + 1) for i in range(3)]
for producer in producers:
    rep = ZmqRep(f, ZmqEndpoint('connect', BROKER_BE_ADDR))
    make_cycle(producer, rep)
github erikkaplun / spinoff / spinoff / actor / zmqdemo / zmqdemo2.py View on Github external
msg = yield self.get()
            print 'CONSUMER %s received %s' % (self.id, msg)


f = ZmqFactory()

BROKER_BE_ADDR = 'ipc://broker-be'
BROKER_FE_ADDR = 'ipc://broker-fe'


broker = TestBroker()

make_cycle(ZmqRouter(f, ZmqEndpoint('bind', BROKER_FE_ADDR)),
           ('frontend', broker, 'frontend'))

make_cycle(ZmqReq(f, ZmqEndpoint('bind', BROKER_BE_ADDR)),
           ('backend', broker, 'backend'))



consumers = [TestConsumer(i + 1) for i in range(3)]
for consumer in consumers:
    dealer = ZmqDealer(f, BROKER_FE_ADDR)
    make_cycle(consumer, dealer)

producers = [TestProducer(i + 1) for i in range(3)]
for producer in producers:
    rep = ZmqRep(f, ZmqEndpoint('connect', BROKER_BE_ADDR))
    make_cycle(producer, rep)


application = Application(producers, [broker], consumers)