Beispiel #1
0
    def locate(self, service_type):
        """
        获取服务连接:从pandora获取服务信息,并连接相关服务端口
        :param service_type:服务类型
        :return:connection
        """
        locate_service_dic = locate(self.pandora_http_client, service_type)
        key_ls = filter(lambda p:p =="https" or p == "http", locate_service_dic.keys())
        if not key_ls:
            return None

        protocol = key_ls[0]
        host = locate_service_dic.get(protocol, None)
        if not host:
            return None

        connection = self.connect_dic.get(host, None)
        if not connection:
            ip, port = host.split(":")
            connection = HttpRpcClient(ip, port, protocol == "https")
            assert connection
            self.connect_dic[host] = connection
        return connection
Beispiel #2
0
    def locate(self, service_type):
        """
        获取服务连接:从pandora获取服务信息,并连接相关服务端口
        :param service_type:服务类型
        :return:connection
        """
        locate_service_dic = locate(self.pandora_http_client, service_type)
        key_ls = filter(lambda p: p == "https" or p == "http",
                        locate_service_dic.keys())
        if not key_ls:
            return None

        protocol = key_ls[0]
        host = locate_service_dic.get(protocol, None)
        if not host:
            return None

        connection = self.connect_dic.get(host, None)
        if not connection:
            ip, port = host.split(":")
            connection = HttpRpcClient(ip, port, protocol == "https")
            assert connection
            self.connect_dic[host] = connection
        return connection
 def test_pandora_tp_locate(self):
     for service in TP_SERVICE_FOR_PANDORA:
         self.assertTrue(locate(PandoraHttpClt, service))
 def test_pandora_locate(self):
     self.assertTrue(locate(PandoraHttpClt, ST_REGISTER))
     for service in SERVICE_FOR_PANDORA:
         self.assertTrue(locate(PandoraHttpClt, service))
Beispiel #5
0
 def test_pandora_tp_locate(self):
     for service in TP_SERVICE_FOR_PANDORA:
         self.assertTrue(locate(PandoraHttpClt, service))
Beispiel #6
0
 def test_pandora_locate(self):
     self.assertTrue(locate(PandoraHttpClt, ST_PANDORA))
     for service in SERVICE_FOR_PANDORA:
         self.assertTrue(locate(PandoraHttpClt, service))