How to use the txzmq.ZmqPubConnection 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 lightningd / plugins / zmq / cl-zmq.py View on Github external
def load_setup(self, setup):
        for e, s in setup.items():
            endpoint = ZmqEndpoint(ZmqEndpointType.bind, e)
            ZmqPubConnection.highWaterMark = s['high_water_mark']
            connection = ZmqPubConnection(self.factory, endpoint)
            for n in s['notification_type_names']:
                self.connection_map[n] = connection
github MediaMath / qasino / lib / zmq_publisher.py View on Github external
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from txzmq import ZmqFactory, ZmqEndpoint, ZmqEndpointType, ZmqPubConnection

import logging

import json

from util import Identity

class ZmqPublisher(ZmqPubConnection):

    def __init__(self, zmq_factory, port, data_manager=None):

        self.data_manager = data_manager

        endpoint = ZmqEndpoint(ZmqEndpointType.bind, "tcp://*:%d" % port)

        ZmqPubConnection.__init__(self, zmq_factory, endpoint)


    def send_generation_signal(self, generation_number, generation_duration_s):
        msg = { "op" : "generation_signal", "identity" : Identity.get_identity(), "generation_number" : generation_number }
        if generation_duration_s:
            msg["generation_duration_s"] = generation_duration_s

        self.publish(json.dumps(msg), "GENSIG")
github lightningd / plugins / zmq / cl-zmq.py View on Github external
def load_setup(self, setup):
        for e, s in setup.items():
            endpoint = ZmqEndpoint(ZmqEndpointType.bind, e)
            ZmqPubConnection.highWaterMark = s['high_water_mark']
            connection = ZmqPubConnection(self.factory, endpoint)
            for n in s['notification_type_names']:
                self.connection_map[n] = connection
github brotchie / ib-zmq / ibzmq / proxy.py View on Github external
def main(config):
    zmq_requests_factory = ZmqFactory()
    zmq_requests_endpoint = ZmqEndpoint(ZmqEndpointType.bind, config['endpoint.command'])
    zmq_requests = ZmqRequests(zmq_requests_factory, zmq_requests_endpoint)

    zmq_broadcast_factory = ZmqFactory()
    zmq_broadcast_endpoint = ZmqEndpoint(ZmqEndpointType.bind, config['endpoint.broadcast'])
    zmq_broadcast = ZmqPubConnection(zmq_broadcast_factory, zmq_broadcast_endpoint)

    api_endpoint = TCP4ClientEndpoint(reactor, config['ibtws.host'], config['ibtws.port'])
    api_endpoint.connect(IBTWSProtocolFactory(zmq_requests, zmq_broadcast))
    reactor.run()
github leapcode / leap_pycommon / src / leap / common / events / server.py View on Github external
def __init__(self, emit_addr, reg_addr):
        """
        Initialize the events server.

        :param emit_addr: The address in which to receive events from clients.
        :type emit_addr: str
        :param reg_addr: The address to which publish events to clients.
        :type reg_addr: str
        """
        TxZmqServerComponent.__init__(self)
        # bind PULL and PUB sockets
        self._pull, self.pull_port = self._zmq_bind(
            txzmq.ZmqPullConnection, emit_addr)
        self._pub, self.pub_port = self._zmq_bind(
            txzmq.ZmqPubConnection, reg_addr)
        # set a handler for arriving messages
        self._pull.onPull = self._onPull