nacos-sdk-python 2.0.0b3__tar.gz → 2.0.0b5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/PKG-INFO +6 -2
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/README.md +5 -1
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/nacos/client.py +4 -4
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/nacos_sdk_python.egg-info/PKG-INFO +6 -2
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/setup.py +1 -1
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/common/client_config.py +1 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/common/client_config_builder.py +8 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/config/remote/config_grpc_client_proxy.py +1 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/naming/remote/naming_grpc_client_proxy.py +1 -0
- nacos-sdk-python-2.0.0b5/v2/nacos/transport/grpcauto/nacos_grpc_service_pb2.py +51 -0
- nacos-sdk-python-2.0.0b5/v2/nacos/transport/grpcauto/nacos_grpc_service_pb2_grpc.py +244 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/transport/http_agent.py +2 -2
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/transport/nacos_server_connector.py +17 -14
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/transport/rpc_client.py +98 -69
- nacos-sdk-python-2.0.0b3/v2/nacos/transport/grpcauto/nacos_grpc_service_pb2.py +0 -264
- nacos-sdk-python-2.0.0b3/v2/nacos/transport/grpcauto/nacos_grpc_service_pb2_grpc.py +0 -191
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/nacos/__init__.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/nacos/commons.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/nacos/exception.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/nacos/files.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/nacos/listener.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/nacos/params.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/nacos/task.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/nacos/timer.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/nacos_sdk_python.egg-info/SOURCES.txt +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/nacos_sdk_python.egg-info/dependency_links.txt +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/nacos_sdk_python.egg-info/requires.txt +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/nacos_sdk_python.egg-info/top_level.txt +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/setup.cfg +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/__init__.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/__init__.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/common/__init__.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/common/constants.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/common/nacos_exception.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/common/payload_registry.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/common/preserved_metadata_key.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/config/__init__.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/config/cache/__init__.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/config/cache/config_info_cache.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/config/cache/config_subscribe_manager.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/config/encryption/__init__.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/config/encryption/kms_client.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/config/encryption/kms_handler.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/config/encryption/plugin/__init__.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/config/encryption/plugin/encryption_plugin.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/config/encryption/plugin/kms_aes_128_encrytion_plugin.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/config/encryption/plugin/kms_aes_256_encrytion_plugin.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/config/encryption/plugin/kms_base_encryption_plugin.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/config/encryption/plugin/kms_encrytion_plugin.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/config/filter/__init__.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/config/filter/config_encryption_filter.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/config/filter/config_filter.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/config/model/__init__.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/config/model/config.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/config/model/config_param.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/config/model/config_request.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/config/model/config_response.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/config/nacos_config_service.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/config/remote/__init__.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/config/remote/config_change_notify_request_handler.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/config/remote/config_grpc_connection_event_listener.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/config/util/__init__.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/config/util/config_client_util.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/nacos_client.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/naming/__init__.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/naming/cache/__init__.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/naming/cache/service_info_cache.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/naming/cache/subscribe_manager.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/naming/event/__init__.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/naming/event/instance_change_notifier.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/naming/model/__init__.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/naming/model/instance.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/naming/model/naming_param.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/naming/model/naming_request.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/naming/model/naming_response.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/naming/model/service.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/naming/nacos_naming_service.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/naming/remote/__init__.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/naming/remote/naming_grpc_connection_event_listener.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/naming/remote/naming_push_request_handler.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/naming/util/__init__.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/naming/util/naming_client_util.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/naming/util/naming_remote_constants.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/proto/__init__.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/transport/__init__.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/transport/auth_client.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/transport/connection.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/transport/connection_event_listener.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/transport/grpc_client.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/transport/grpc_connection.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/transport/grpc_util.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/transport/grpcauto/__init__.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/transport/model/__init__.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/transport/model/internal_request.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/transport/model/internal_response.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/transport/model/rpc_request.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/transport/model/rpc_response.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/transport/model/server_info.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/transport/rpc_client_factory.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/transport/server_request_handler.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/utils/__init__.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/utils/aes_util.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/utils/common_util.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/utils/content_util.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/utils/encode_util.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/utils/file_util.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/utils/hmac_util.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/utils/md5_util.py +0 -0
- {nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/utils/net_util.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: nacos-sdk-python
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.0b5
|
|
4
4
|
Summary: Python client for Nacos.
|
|
5
5
|
Home-page: https://github.com/nacos-group/nacos-sdk-python
|
|
6
6
|
Author: nacos
|
|
@@ -304,12 +304,16 @@ Description:
|
|
|
304
304
|
## Installation
|
|
305
305
|
|
|
306
306
|
```shell
|
|
307
|
-
|
|
307
|
+
pip install nacos-sdk-python==2.0.0b4
|
|
308
308
|
```
|
|
309
309
|
|
|
310
310
|
## Client Configuration
|
|
311
311
|
|
|
312
312
|
```
|
|
313
|
+
from v2.nacos import NacosNamingService, ClientConfigBuilder, GRPCConfig, Instance, SubscribeServiceParam, \
|
|
314
|
+
RegisterInstanceParam, DeregisterInstanceParam, BatchRegisterInstanceParam, GetServiceParam, ListServiceParam, \
|
|
315
|
+
ListInstanceParam, NacosConfigService, ConfigParam
|
|
316
|
+
|
|
313
317
|
client_config = (ClientConfigBuilder()
|
|
314
318
|
.access_key(os.getenv('NACOS_ACCESS_KEY'))
|
|
315
319
|
.secret_key(os.getenv('NACOS_SECRET_KEY'))
|
|
@@ -292,12 +292,16 @@ Supported Nacos version over 2.x
|
|
|
292
292
|
## Installation
|
|
293
293
|
|
|
294
294
|
```shell
|
|
295
|
-
pip install nacos-sdk-python
|
|
295
|
+
pip install nacos-sdk-python==2.0.0b4
|
|
296
296
|
```
|
|
297
297
|
|
|
298
298
|
## Client Configuration
|
|
299
299
|
|
|
300
300
|
```
|
|
301
|
+
from v2.nacos import NacosNamingService, ClientConfigBuilder, GRPCConfig, Instance, SubscribeServiceParam, \
|
|
302
|
+
RegisterInstanceParam, DeregisterInstanceParam, BatchRegisterInstanceParam, GetServiceParam, ListServiceParam, \
|
|
303
|
+
ListInstanceParam, NacosConfigService, ConfigParam
|
|
304
|
+
|
|
301
305
|
client_config = (ClientConfigBuilder()
|
|
302
306
|
.access_key(os.getenv('NACOS_ACCESS_KEY'))
|
|
303
307
|
.secret_key(os.getenv('NACOS_SECRET_KEY'))
|
|
@@ -341,7 +341,7 @@ class NacosClient:
|
|
|
341
341
|
self.proxies = None
|
|
342
342
|
self.logDir = logDir
|
|
343
343
|
|
|
344
|
-
self.heartbeats
|
|
344
|
+
self.heartbeats = {}
|
|
345
345
|
if self.username and self.password:
|
|
346
346
|
self.get_access_token()
|
|
347
347
|
logger.info("[client-init] endpoint:%s, tenant:%s" % (endpoint, namespace))
|
|
@@ -1150,8 +1150,8 @@ class NacosClient:
|
|
|
1150
1150
|
|
|
1151
1151
|
def send_heartbeat(self, service_name, ip, port, cluster_name=None, weight=1.0, metadata=None, ephemeral=True,
|
|
1152
1152
|
group_name=DEFAULT_GROUP_NAME):
|
|
1153
|
-
logger.
|
|
1154
|
-
|
|
1153
|
+
logger.debug("[send-heartbeat] ip:%s, port:%s, service_name:%s, namespace:%s" % (ip, port, service_name,
|
|
1154
|
+
self.namespace))
|
|
1155
1155
|
if "@@" not in service_name and group_name:
|
|
1156
1156
|
service_name = group_name + "@@" + service_name
|
|
1157
1157
|
|
|
@@ -1186,7 +1186,7 @@ class NacosClient:
|
|
|
1186
1186
|
resp = self._do_sync_req("/nacos/v1/ns/instance/beat", None, params, None, self.default_timeout, "PUT",
|
|
1187
1187
|
"naming")
|
|
1188
1188
|
c = resp.read()
|
|
1189
|
-
logger.
|
|
1189
|
+
logger.debug("[send-heartbeat] ip:%s, port:%s, service_name:%s, namespace:%s, server response:%s" %
|
|
1190
1190
|
(ip, port, service_name, self.namespace, c))
|
|
1191
1191
|
return json.loads(c.decode("UTF-8"))
|
|
1192
1192
|
except HTTPError as e:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: nacos-sdk-python
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.0b5
|
|
4
4
|
Summary: Python client for Nacos.
|
|
5
5
|
Home-page: https://github.com/nacos-group/nacos-sdk-python
|
|
6
6
|
Author: nacos
|
|
@@ -304,12 +304,16 @@ Description:
|
|
|
304
304
|
## Installation
|
|
305
305
|
|
|
306
306
|
```shell
|
|
307
|
-
|
|
307
|
+
pip install nacos-sdk-python==2.0.0b4
|
|
308
308
|
```
|
|
309
309
|
|
|
310
310
|
## Client Configuration
|
|
311
311
|
|
|
312
312
|
```
|
|
313
|
+
from v2.nacos import NacosNamingService, ClientConfigBuilder, GRPCConfig, Instance, SubscribeServiceParam, \
|
|
314
|
+
RegisterInstanceParam, DeregisterInstanceParam, BatchRegisterInstanceParam, GetServiceParam, ListServiceParam, \
|
|
315
|
+
ListInstanceParam, NacosConfigService, ConfigParam
|
|
316
|
+
|
|
313
317
|
client_config = (ClientConfigBuilder()
|
|
314
318
|
.access_key(os.getenv('NACOS_ACCESS_KEY'))
|
|
315
319
|
.secret_key(os.getenv('NACOS_SECRET_KEY'))
|
|
@@ -53,7 +53,7 @@ class UploadCommand(Command):
|
|
|
53
53
|
|
|
54
54
|
setup(
|
|
55
55
|
name="nacos-sdk-python",
|
|
56
|
-
version="2.0.0.
|
|
56
|
+
version="2.0.0.beta5",
|
|
57
57
|
packages=find_packages(
|
|
58
58
|
exclude=["test", "*.tests", "*.tests.*", "tests.*", "tests"]),
|
|
59
59
|
url="https://github.com/nacos-group/nacos-sdk-python",
|
{nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/common/client_config_builder.py
RENAMED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from typing import Dict, List
|
|
2
|
+
|
|
1
3
|
from v2.nacos.common.client_config import ClientConfig, GRPCConfig
|
|
2
4
|
from v2.nacos.common.client_config import KMSConfig
|
|
3
5
|
from v2.nacos.common.client_config import TLSConfig
|
|
@@ -82,5 +84,11 @@ class ClientConfigBuilder:
|
|
|
82
84
|
self._config.app_conn_labels.update(app_conn_labels)
|
|
83
85
|
return self
|
|
84
86
|
|
|
87
|
+
def endpoint_query_header(self, endpoint_query_header: Dict[str, str]) -> "ClientConfigBuilder":
|
|
88
|
+
if self._config.endpoint_query_header is None:
|
|
89
|
+
self._config.endpoint_query_header = {}
|
|
90
|
+
self._config.endpoint_query_header.update(endpoint_query_header)
|
|
91
|
+
return self
|
|
92
|
+
|
|
85
93
|
def build(self):
|
|
86
94
|
return self._config
|
|
@@ -47,6 +47,7 @@ class NamingGRPCClientProxy:
|
|
|
47
47
|
self.event_listener = NamingGrpcConnectionEventListener(self)
|
|
48
48
|
|
|
49
49
|
async def start(self):
|
|
50
|
+
await self.nacos_server_connector.init()
|
|
50
51
|
labels = {Constants.LABEL_SOURCE: Constants.LABEL_SOURCE_SDK,
|
|
51
52
|
Constants.LABEL_MODULE: Constants.NAMING_MODULE}
|
|
52
53
|
self.rpc_client = await RpcClientFactory(self.logger).create_client(str(self.uuid), ConnectionType.GRPC, labels,
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
|
+
# NO CHECKED-IN PROTOBUF GENCODE
|
|
4
|
+
# source: nacos_grpc_service.proto
|
|
5
|
+
# Protobuf Python Version: 5.27.2
|
|
6
|
+
"""Generated protocol buffer code."""
|
|
7
|
+
from google.protobuf import descriptor as _descriptor
|
|
8
|
+
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
9
|
+
from google.protobuf import runtime_version as _runtime_version
|
|
10
|
+
from google.protobuf import symbol_database as _symbol_database
|
|
11
|
+
from google.protobuf.internal import builder as _builder
|
|
12
|
+
_runtime_version.ValidateProtobufRuntimeVersion(
|
|
13
|
+
_runtime_version.Domain.PUBLIC,
|
|
14
|
+
5,
|
|
15
|
+
27,
|
|
16
|
+
2,
|
|
17
|
+
'',
|
|
18
|
+
'nacos_grpc_service.proto'
|
|
19
|
+
)
|
|
20
|
+
# @@protoc_insertion_point(imports)
|
|
21
|
+
|
|
22
|
+
_sym_db = _symbol_database.Default()
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
from google.protobuf import any_pb2 as google_dot_protobuf_dot_any__pb2
|
|
26
|
+
from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x18nacos_grpc_service.proto\x1a\x19google/protobuf/any.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\x83\x01\n\x08Metadata\x12\x0c\n\x04type\x18\x03 \x01(\t\x12\x10\n\x08\x63lientIp\x18\x08 \x01(\t\x12\'\n\x07headers\x18\x07 \x03(\x0b\x32\x16.Metadata.HeadersEntry\x1a.\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"J\n\x07Payload\x12\x1b\n\x08metadata\x18\x02 \x01(\x0b\x32\t.Metadata\x12\"\n\x04\x62ody\x18\x03 \x01(\x0b\x32\x14.google.protobuf.Any28\n\rRequestStream\x12\'\n\rrequestStream\x12\x08.Payload\x1a\x08.Payload\"\x00\x30\x01\x32*\n\x07Request\x12\x1f\n\x07request\x12\x08.Payload\x1a\x08.Payload\"\x00\x32>\n\x0f\x42iRequestStream\x12+\n\x0frequestBiStream\x12\x08.Payload\x1a\x08.Payload\"\x00(\x01\x30\x01\x42#\n\x1f\x63om.alibaba.nacos.api.grpc.autoP\x01\x62\x06proto3')
|
|
30
|
+
|
|
31
|
+
_globals = globals()
|
|
32
|
+
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
|
33
|
+
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'nacos_grpc_service_pb2', _globals)
|
|
34
|
+
if not _descriptor._USE_C_DESCRIPTORS:
|
|
35
|
+
_globals['DESCRIPTOR']._loaded_options = None
|
|
36
|
+
_globals['DESCRIPTOR']._serialized_options = b'\n\037com.alibaba.nacos.api.grpc.autoP\001'
|
|
37
|
+
_globals['_METADATA_HEADERSENTRY']._loaded_options = None
|
|
38
|
+
_globals['_METADATA_HEADERSENTRY']._serialized_options = b'8\001'
|
|
39
|
+
_globals['_METADATA']._serialized_start=89
|
|
40
|
+
_globals['_METADATA']._serialized_end=220
|
|
41
|
+
_globals['_METADATA_HEADERSENTRY']._serialized_start=174
|
|
42
|
+
_globals['_METADATA_HEADERSENTRY']._serialized_end=220
|
|
43
|
+
_globals['_PAYLOAD']._serialized_start=222
|
|
44
|
+
_globals['_PAYLOAD']._serialized_end=296
|
|
45
|
+
_globals['_REQUESTSTREAM']._serialized_start=298
|
|
46
|
+
_globals['_REQUESTSTREAM']._serialized_end=354
|
|
47
|
+
_globals['_REQUEST']._serialized_start=356
|
|
48
|
+
_globals['_REQUEST']._serialized_end=398
|
|
49
|
+
_globals['_BIREQUESTSTREAM']._serialized_start=400
|
|
50
|
+
_globals['_BIREQUESTSTREAM']._serialized_end=462
|
|
51
|
+
# @@protoc_insertion_point(module_scope)
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
|
|
2
|
+
"""Client and server classes corresponding to protobuf-defined services."""
|
|
3
|
+
import grpc
|
|
4
|
+
|
|
5
|
+
import v2.nacos.transport.grpcauto.nacos_grpc_service_pb2 as nacos__grpc__service__pb2
|
|
6
|
+
|
|
7
|
+
GRPC_GENERATED_VERSION = '1.66.1'
|
|
8
|
+
GRPC_VERSION = grpc.__version__
|
|
9
|
+
_version_not_supported = False
|
|
10
|
+
|
|
11
|
+
try:
|
|
12
|
+
from grpc._utilities import first_version_is_lower
|
|
13
|
+
|
|
14
|
+
_version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
|
|
15
|
+
except ImportError:
|
|
16
|
+
_version_not_supported = True
|
|
17
|
+
|
|
18
|
+
if _version_not_supported:
|
|
19
|
+
raise RuntimeError(
|
|
20
|
+
f'The grpc package installed is at version {GRPC_VERSION},'
|
|
21
|
+
+ f' but the generated code in nacos_grpc_service_pb2_grpc.py depends on'
|
|
22
|
+
+ f' grpcio>={GRPC_GENERATED_VERSION}.'
|
|
23
|
+
+ f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
|
|
24
|
+
+ f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class RequestStreamStub(object):
|
|
29
|
+
"""Missing associated documentation comment in .proto file."""
|
|
30
|
+
|
|
31
|
+
def __init__(self, channel):
|
|
32
|
+
"""Constructor.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
channel: A grpc.Channel.
|
|
36
|
+
"""
|
|
37
|
+
self.requestStream = channel.unary_stream(
|
|
38
|
+
'/RequestStream/requestStream',
|
|
39
|
+
request_serializer=nacos__grpc__service__pb2.Payload.SerializeToString,
|
|
40
|
+
response_deserializer=nacos__grpc__service__pb2.Payload.FromString,
|
|
41
|
+
_registered_method=True)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class RequestStreamServicer(object):
|
|
45
|
+
"""Missing associated documentation comment in .proto file."""
|
|
46
|
+
|
|
47
|
+
def requestStream(self, request, context):
|
|
48
|
+
"""build a streamRequest
|
|
49
|
+
"""
|
|
50
|
+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
|
51
|
+
context.set_details('Method not implemented!')
|
|
52
|
+
raise NotImplementedError('Method not implemented!')
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def add_RequestStreamServicer_to_server(servicer, server):
|
|
56
|
+
rpc_method_handlers = {
|
|
57
|
+
'requestStream': grpc.unary_stream_rpc_method_handler(
|
|
58
|
+
servicer.requestStream,
|
|
59
|
+
request_deserializer=nacos__grpc__service__pb2.Payload.FromString,
|
|
60
|
+
response_serializer=nacos__grpc__service__pb2.Payload.SerializeToString,
|
|
61
|
+
),
|
|
62
|
+
}
|
|
63
|
+
generic_handler = grpc.method_handlers_generic_handler(
|
|
64
|
+
'RequestStream', rpc_method_handlers)
|
|
65
|
+
server.add_generic_rpc_handlers((generic_handler,))
|
|
66
|
+
server.add_registered_method_handlers('RequestStream', rpc_method_handlers)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
# This class is part of an EXPERIMENTAL API.
|
|
70
|
+
class RequestStream(object):
|
|
71
|
+
"""Missing associated documentation comment in .proto file."""
|
|
72
|
+
|
|
73
|
+
@staticmethod
|
|
74
|
+
def requestStream(request,
|
|
75
|
+
target,
|
|
76
|
+
options=(),
|
|
77
|
+
channel_credentials=None,
|
|
78
|
+
call_credentials=None,
|
|
79
|
+
insecure=False,
|
|
80
|
+
compression=None,
|
|
81
|
+
wait_for_ready=None,
|
|
82
|
+
timeout=None,
|
|
83
|
+
metadata=None):
|
|
84
|
+
return grpc.experimental.unary_stream(
|
|
85
|
+
request,
|
|
86
|
+
target,
|
|
87
|
+
'/RequestStream/requestStream',
|
|
88
|
+
nacos__grpc__service__pb2.Payload.SerializeToString,
|
|
89
|
+
nacos__grpc__service__pb2.Payload.FromString,
|
|
90
|
+
options,
|
|
91
|
+
channel_credentials,
|
|
92
|
+
insecure,
|
|
93
|
+
call_credentials,
|
|
94
|
+
compression,
|
|
95
|
+
wait_for_ready,
|
|
96
|
+
timeout,
|
|
97
|
+
metadata,
|
|
98
|
+
_registered_method=True)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
class RequestStub(object):
|
|
102
|
+
"""Missing associated documentation comment in .proto file."""
|
|
103
|
+
|
|
104
|
+
def __init__(self, channel):
|
|
105
|
+
"""Constructor.
|
|
106
|
+
|
|
107
|
+
Args:
|
|
108
|
+
channel: A grpc.Channel.
|
|
109
|
+
"""
|
|
110
|
+
self.request = channel.unary_unary(
|
|
111
|
+
'/Request/request',
|
|
112
|
+
request_serializer=nacos__grpc__service__pb2.Payload.SerializeToString,
|
|
113
|
+
response_deserializer=nacos__grpc__service__pb2.Payload.FromString,
|
|
114
|
+
_registered_method=True)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
class RequestServicer(object):
|
|
118
|
+
"""Missing associated documentation comment in .proto file."""
|
|
119
|
+
|
|
120
|
+
def request(self, request, context):
|
|
121
|
+
"""Sends a commonRequest
|
|
122
|
+
"""
|
|
123
|
+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
|
124
|
+
context.set_details('Method not implemented!')
|
|
125
|
+
raise NotImplementedError('Method not implemented!')
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def add_RequestServicer_to_server(servicer, server):
|
|
129
|
+
rpc_method_handlers = {
|
|
130
|
+
'request': grpc.unary_unary_rpc_method_handler(
|
|
131
|
+
servicer.request,
|
|
132
|
+
request_deserializer=nacos__grpc__service__pb2.Payload.FromString,
|
|
133
|
+
response_serializer=nacos__grpc__service__pb2.Payload.SerializeToString,
|
|
134
|
+
),
|
|
135
|
+
}
|
|
136
|
+
generic_handler = grpc.method_handlers_generic_handler(
|
|
137
|
+
'Request', rpc_method_handlers)
|
|
138
|
+
server.add_generic_rpc_handlers((generic_handler,))
|
|
139
|
+
server.add_registered_method_handlers('Request', rpc_method_handlers)
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
# This class is part of an EXPERIMENTAL API.
|
|
143
|
+
class Request(object):
|
|
144
|
+
"""Missing associated documentation comment in .proto file."""
|
|
145
|
+
|
|
146
|
+
@staticmethod
|
|
147
|
+
def request(request,
|
|
148
|
+
target,
|
|
149
|
+
options=(),
|
|
150
|
+
channel_credentials=None,
|
|
151
|
+
call_credentials=None,
|
|
152
|
+
insecure=False,
|
|
153
|
+
compression=None,
|
|
154
|
+
wait_for_ready=None,
|
|
155
|
+
timeout=None,
|
|
156
|
+
metadata=None):
|
|
157
|
+
return grpc.experimental.unary_unary(
|
|
158
|
+
request,
|
|
159
|
+
target,
|
|
160
|
+
'/Request/request',
|
|
161
|
+
nacos__grpc__service__pb2.Payload.SerializeToString,
|
|
162
|
+
nacos__grpc__service__pb2.Payload.FromString,
|
|
163
|
+
options,
|
|
164
|
+
channel_credentials,
|
|
165
|
+
insecure,
|
|
166
|
+
call_credentials,
|
|
167
|
+
compression,
|
|
168
|
+
wait_for_ready,
|
|
169
|
+
timeout,
|
|
170
|
+
metadata,
|
|
171
|
+
_registered_method=True)
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
class BiRequestStreamStub(object):
|
|
175
|
+
"""Missing associated documentation comment in .proto file."""
|
|
176
|
+
|
|
177
|
+
def __init__(self, channel):
|
|
178
|
+
"""Constructor.
|
|
179
|
+
|
|
180
|
+
Args:
|
|
181
|
+
channel: A grpc.Channel.
|
|
182
|
+
"""
|
|
183
|
+
self.requestBiStream = channel.stream_stream(
|
|
184
|
+
'/BiRequestStream/requestBiStream',
|
|
185
|
+
request_serializer=nacos__grpc__service__pb2.Payload.SerializeToString,
|
|
186
|
+
response_deserializer=nacos__grpc__service__pb2.Payload.FromString,
|
|
187
|
+
_registered_method=True)
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
class BiRequestStreamServicer(object):
|
|
191
|
+
"""Missing associated documentation comment in .proto file."""
|
|
192
|
+
|
|
193
|
+
def requestBiStream(self, request_iterator, context):
|
|
194
|
+
"""Sends a commonRequest
|
|
195
|
+
"""
|
|
196
|
+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
|
197
|
+
context.set_details('Method not implemented!')
|
|
198
|
+
raise NotImplementedError('Method not implemented!')
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
def add_BiRequestStreamServicer_to_server(servicer, server):
|
|
202
|
+
rpc_method_handlers = {
|
|
203
|
+
'requestBiStream': grpc.stream_stream_rpc_method_handler(
|
|
204
|
+
servicer.requestBiStream,
|
|
205
|
+
request_deserializer=nacos__grpc__service__pb2.Payload.FromString,
|
|
206
|
+
response_serializer=nacos__grpc__service__pb2.Payload.SerializeToString,
|
|
207
|
+
),
|
|
208
|
+
}
|
|
209
|
+
generic_handler = grpc.method_handlers_generic_handler(
|
|
210
|
+
'BiRequestStream', rpc_method_handlers)
|
|
211
|
+
server.add_generic_rpc_handlers((generic_handler,))
|
|
212
|
+
server.add_registered_method_handlers('BiRequestStream', rpc_method_handlers)
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
# This class is part of an EXPERIMENTAL API.
|
|
216
|
+
class BiRequestStream(object):
|
|
217
|
+
"""Missing associated documentation comment in .proto file."""
|
|
218
|
+
|
|
219
|
+
@staticmethod
|
|
220
|
+
def requestBiStream(request_iterator,
|
|
221
|
+
target,
|
|
222
|
+
options=(),
|
|
223
|
+
channel_credentials=None,
|
|
224
|
+
call_credentials=None,
|
|
225
|
+
insecure=False,
|
|
226
|
+
compression=None,
|
|
227
|
+
wait_for_ready=None,
|
|
228
|
+
timeout=None,
|
|
229
|
+
metadata=None):
|
|
230
|
+
return grpc.experimental.stream_stream(
|
|
231
|
+
request_iterator,
|
|
232
|
+
target,
|
|
233
|
+
'/BiRequestStream/requestBiStream',
|
|
234
|
+
nacos__grpc__service__pb2.Payload.SerializeToString,
|
|
235
|
+
nacos__grpc__service__pb2.Payload.FromString,
|
|
236
|
+
options,
|
|
237
|
+
channel_credentials,
|
|
238
|
+
insecure,
|
|
239
|
+
call_credentials,
|
|
240
|
+
compression,
|
|
241
|
+
wait_for_ready,
|
|
242
|
+
timeout,
|
|
243
|
+
metadata,
|
|
244
|
+
_registered_method=True)
|
|
@@ -51,8 +51,8 @@ class HttpAgent:
|
|
|
51
51
|
return None, error_msg
|
|
52
52
|
|
|
53
53
|
except aiohttp.ClientError as e:
|
|
54
|
-
self.logger.
|
|
54
|
+
self.logger.warning(f"[http-request] client error: {e}")
|
|
55
55
|
return None, e
|
|
56
56
|
except Exception as e:
|
|
57
|
-
self.logger.
|
|
57
|
+
self.logger.warning(f"[http-request] unexpected error: {e}")
|
|
58
58
|
return None, e
|
{nacos-sdk-python-2.0.0b3 → nacos-sdk-python-2.0.0b5}/v2/nacos/transport/nacos_server_connector.py
RENAMED
|
@@ -4,7 +4,7 @@ from typing import List, Optional
|
|
|
4
4
|
|
|
5
5
|
from v2.nacos.common.client_config import ClientConfig
|
|
6
6
|
from v2.nacos.common.constants import Constants
|
|
7
|
-
from v2.nacos.common.nacos_exception import NacosException, INVALID_PARAM
|
|
7
|
+
from v2.nacos.common.nacos_exception import NacosException, INVALID_PARAM, INVALID_SERVER_STATUS
|
|
8
8
|
from v2.nacos.transport.auth_client import AuthClient
|
|
9
9
|
from v2.nacos.transport.http_agent import HttpAgent
|
|
10
10
|
|
|
@@ -23,19 +23,20 @@ class NacosServerConnector:
|
|
|
23
23
|
self.endpoint = client_config.endpoint
|
|
24
24
|
self.server_list_lock = asyncio.Lock()
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
self.
|
|
29
|
-
asyncio.create_task(self._refresh_server_srv_if_need())
|
|
30
|
-
|
|
31
|
-
if len(self.server_list) == 0:
|
|
32
|
-
raise NacosException(INVALID_PARAM, "server list is empty")
|
|
26
|
+
self.refresh_server_list_internal = 30 # second
|
|
27
|
+
if len(self.server_list) != 0:
|
|
28
|
+
self.current_index = randrange(0, len(self.server_list))
|
|
33
29
|
|
|
34
|
-
self.current_index = randrange(0, len(self.server_list))
|
|
35
30
|
if client_config.username and client_config.password:
|
|
36
31
|
self.auth_client = AuthClient(self.logger, client_config, self.get_server_list, http_agent)
|
|
37
32
|
asyncio.create_task(self.auth_client.get_access_token(True))
|
|
38
33
|
|
|
34
|
+
async def init(self):
|
|
35
|
+
await self._get_server_list_from_endpoint()
|
|
36
|
+
if len(self.server_list) == 0:
|
|
37
|
+
raise NacosException(INVALID_SERVER_STATUS, "server list is empty")
|
|
38
|
+
asyncio.create_task(self._refresh_server_srv_if_need())
|
|
39
|
+
|
|
39
40
|
async def _get_server_list_from_endpoint(self) -> Optional[List[str]]:
|
|
40
41
|
if not self.endpoint or self.endpoint.strip() == "":
|
|
41
42
|
return None
|
|
@@ -43,7 +44,8 @@ class NacosServerConnector:
|
|
|
43
44
|
url = self.endpoint.strip() + self.client_config.endpoint_context_path + "/serverlist"
|
|
44
45
|
server_list = []
|
|
45
46
|
try:
|
|
46
|
-
response, err = await self.http_agent.request(url, "GET",
|
|
47
|
+
response, err = await self.http_agent.request(url, "GET", self.client_config.endpoint_query_header, None,
|
|
48
|
+
None)
|
|
47
49
|
if err:
|
|
48
50
|
self.logger.error("[get-server-list] get server list from endpoint failed,url:%s, err:%s", url, err)
|
|
49
51
|
return None
|
|
@@ -53,15 +55,16 @@ class NacosServerConnector:
|
|
|
53
55
|
for server_info in response.decode('utf-8').strip().split("\n"):
|
|
54
56
|
sp = server_info.strip().split(":")
|
|
55
57
|
if len(sp) == 1:
|
|
56
|
-
server_list.append((sp[0] + ":" + Constants.DEFAULT_PORT))
|
|
58
|
+
server_list.append((sp[0] + ":" + str(Constants.DEFAULT_PORT)))
|
|
57
59
|
else:
|
|
58
60
|
server_list.append(server_info)
|
|
59
61
|
|
|
60
62
|
if len(server_list) != 0 and set(server_list) != set(self.server_list):
|
|
61
|
-
with self.server_list_lock:
|
|
63
|
+
async with self.server_list_lock:
|
|
62
64
|
old_server_list = self.server_list
|
|
63
65
|
self.server_list = server_list
|
|
64
|
-
self.
|
|
66
|
+
self.current_index = randrange(0, len(self.server_list))
|
|
67
|
+
self.logger.info("nacos server list is updated from %s to %s",
|
|
65
68
|
str(old_server_list), str(server_list))
|
|
66
69
|
except Exception as e:
|
|
67
70
|
self.logger.error("[get-server-list] get server list from endpoint failed,url:%s, err:%s", url, e)
|
|
@@ -81,7 +84,7 @@ class NacosServerConnector:
|
|
|
81
84
|
|
|
82
85
|
def get_next_server(self):
|
|
83
86
|
if not self.server_list:
|
|
84
|
-
raise
|
|
87
|
+
raise NacosException(INVALID_SERVER_STATUS, 'server list is empty')
|
|
85
88
|
self.current_index = (self.current_index + 1) % len(self.server_list)
|
|
86
89
|
return self.server_list[self.current_index]
|
|
87
90
|
|