def __init__(self,
              address,
              app_name,
              data_center="",
              zone="",
              registry_end_point=None,
              is_antsharecloud=False,
              access_key=None,
              secret_key=None,
              **server_kwargs):
     """
     :param address: the socket address will be listened on.
     :type address: tuple (host:str, port:int)
     Check ApplicationInfo's comment for other params' explanations.
     """
     self.address = address
     self.app_name = app_name
     self.server_kwargs = server_kwargs
     self.handler = self.handlerCls()
     try:
         self._mesh_client = MeshClient(
             ApplicationInfo(app_name, data_center, zone,
                             registry_end_point, access_key, secret_key,
                             is_antsharecloud))
         self._mesh_client.startup()
     except:
         logger.error("Fail to startup mesh client")
         self._mesh_client = None
 def test_pub(self, session_mock):
     session_mock.post('http://127.0.0.1:13330/services/publish',
                       text=json.dumps(dict(success=True)))
     pubreq = PublishServiceRequest(
         serviceName="com.alipay.pybolt.test:1.0",
         providerMetaInfo=ProviderMetaInfo(protocol="1",
                                           version="4.0",
                                           serializeType="protobuf",
                                           appName="pybolt_test_app"))
     print(attr.asdict(pubreq))
     mesh = MeshClient(ApplicationInfo("pybolt_test_app"))
     mesh.publish(pubreq)
Example #3
0
 def __init__(self,
              app_name,
              data_center=None,
              zone=None,
              registry_end_point=None,
              is_antsharecloud=False,
              access_key=None,
              secret_key=None):
     """
     Check ApplicationInfo's comment for params' explanations.
     """
     try:
         self._mesh_client = MeshClient(
             ApplicationInfo(app_name, data_center, zone,
                             registry_end_point, access_key, secret_key,
                             is_antsharecloud))
         self._mesh_client.startup()
     except:
         logger.error("Fail to startup mesh client")
         self._mesh_client = None
Example #4
0
 def test_unsubscribe(self, session_mock):
     print(session_mock)
     session_mock.post('http://127.0.0.1:13330/services/unsubscribe',
                       text=json.dumps(dict(success=True)))
     mesh = MeshClient(ApplicationInfo("pybolt_test_app"))
     mesh.unsubscribe("com.alipay.test")
Example #5
0
 def test_start(self, session_mock):
     session_mock.post('http://127.0.0.1:13330/configs/application',
                       text=json.dumps(dict(success=True)))
     mesh = MeshClient(ApplicationInfo("pybolt_test_app", "", "", ""))
     mesh.startup()