Esempio n. 1
0
    def __init__(self, svc_addr, svc_resp_addr, passphrase):
        """sender_id = uuid.uuid4() or anything unique
        pull_addr = pull socket used for incoming messages
        pub_addr = publish socket used for outgoing messages

        The class encapsulates socket type by referring to it's pull socket
        as in_sock and it's publish socket as out_sock.
        """
        zmq = load_zmq()
        ctx = load_zmq_ctx()

        self.sender_id = uuid4().hex
        self.in_addr = svc_addr
        self.out_addr = svc_resp_addr


        # the request (in_sock) is received from a DEALER socket (round robin)
        self.in_sock = ctx.socket(zmq.PULL)
        self.in_sock.connect(self.in_addr)
        print("Connected service requested PULL socket %s" % (self.in_addr))

        # the response is sent to original clients incoming DEALER socket
        self.out_sock = ctx.socket(zmq.ROUTER)
        self.out_sock.connect(self.out_addr)
        print("Connected service response ROUTER socket %s" % (self.out_addr))

        self.zmq = zmq
        self.passphrase = passphrase
Esempio n. 2
0
    def __init__(self, svc_addr, svc_resp_addr, passphrase):
        """ passphrase = unique ID that both the client and server need to match
                for security purposed

            svc_addr = address of the Brubeck Service we are connecting to
            This socket is used for both inbound and outbound messages
        """

        self.passphrase = passphrase
        self.sender_id = uuid4().hex
        self.out_addr = svc_addr
        self.in_addr = svc_resp_addr
        
        zmq = load_zmq()
        ctx = load_zmq_ctx()

        self.out_sock = ctx.socket(zmq.PUSH)
        self.out_sock.bind(self.out_addr)
        logging.debug("Bound service request PUSH socket %s" % (self.out_addr))

        self.in_sock = ctx.socket(zmq.DEALER)
        self.in_sock.setsockopt(zmq.IDENTITY, self.sender_id)
        self.in_sock.bind(self.in_addr)
        logging.debug("Bound service response DEALER socket %s ID:%s" % (self.in_addr, self.sender_id))

        self.zmq = zmq
Esempio n. 3
0
    def __init__(self, pull_addr, pub_addr):
        """sender_id = uuid.uuid4() or anything unique
        pull_addr = pull socket used for incoming messages
        pub_addr = publish socket used for outgoing messages

        The class encapsulates socket type by referring to it's pull socket
        as in_sock and it's publish socket as out_sock.
        """
        zmq = load_zmq()
        ctx = load_zmq_ctx()
        
        in_sock = ctx.socket(zmq.PULL)
        out_sock = ctx.socket(zmq.PUB)

        super(BrubeckConnection, self).__init__(in_sock, out_sock)
        self.in_addr = pull_addr
        self.out_addr = pub_addr

        in_sock.connect(pull_addr)
        out_sock.setsockopt(zmq.IDENTITY, self.sender_id)
        out_sock.connect(pub_addr)