Compare commits
9 Commits
Author | SHA1 | Date |
---|---|---|
|
df8f9d2dcd | |
|
4600b89e45 | |
|
ce22e6a437 | |
|
b3c26c7ba9 | |
|
cb17109542 | |
|
1892ebbe43 | |
|
bcdda37351 | |
|
d3f9b0daec | |
|
95236b1643 |
|
@ -18,7 +18,7 @@ Supported Nacos version over 2.x
|
|||
## Installation
|
||||
|
||||
```shell
|
||||
pip install nacos-sdk-python==2.0.3
|
||||
pip install nacos-sdk-python
|
||||
```
|
||||
|
||||
## Client Configuration
|
||||
|
|
|
@ -425,7 +425,7 @@ class NacosClient:
|
|||
params["type"] = config_type
|
||||
|
||||
try:
|
||||
resp = self._do_sync_req("/nacos/v1/cs/configs", None, params, None,
|
||||
resp = self._do_sync_req("/nacos/v1/cs/configs", None, None, params,
|
||||
timeout or self.default_timeout, "POST")
|
||||
c = resp.read()
|
||||
logger.info("[publish] publish content, group:%s, data_id:%s, server response:%s" % (
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import asyncio
|
||||
from logging import Logger
|
||||
from typing import Optional, Callable, List
|
||||
from typing import Optional, Callable, List, Dict
|
||||
|
||||
from v2.nacos.common.constants import Constants
|
||||
from v2.nacos.config.cache.config_info_cache import ConfigInfoCache
|
||||
|
@ -15,7 +15,7 @@ class ConfigSubscribeManager:
|
|||
def __init__(self, logger: Logger, config_info_cache: ConfigInfoCache, namespace_id: str,
|
||||
config_filter_chain_manager: ConfigFilterChainManager,
|
||||
execute_config_listen_channel: asyncio.Queue):
|
||||
self.subscribe_cache_map: dict[str, SubscribeCacheData] = {}
|
||||
self.subscribe_cache_map: Dict[str, SubscribeCacheData] = {}
|
||||
self.logger = logger
|
||||
self.lock = asyncio.Lock()
|
||||
self.namespace_id = namespace_id
|
||||
|
@ -87,7 +87,7 @@ class ConfigSubscribeManager:
|
|||
await subscribe_cache.execute_listener()
|
||||
|
||||
async def execute_listener_and_build_tasks(self, is_sync_all: bool):
|
||||
listen_fetch_task_map: dict[int, List[SubscribeCacheData]] = {}
|
||||
listen_fetch_task_map: Dict[int, List[SubscribeCacheData]] = {}
|
||||
for cache_data in self.subscribe_cache_map.values():
|
||||
if cache_data.is_sync_with_server:
|
||||
await cache_data.execute_listener()
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from typing import Dict
|
||||
|
||||
from v2.nacos.common.client_config import KMSConfig
|
||||
from v2.nacos.common.constants import Constants
|
||||
from v2.nacos.common.nacos_exception import NacosException, INVALID_PARAM
|
||||
|
@ -11,7 +13,7 @@ from v2.nacos.config.model.config_param import HandlerParam
|
|||
|
||||
class KMSHandler:
|
||||
def __init__(self, kms_config: KMSConfig):
|
||||
self.kms_plugins: dict[str, EncryptionPlugin] = {}
|
||||
self.kms_plugins: Dict[str, EncryptionPlugin] = {}
|
||||
self.kms_client = KmsClient.create_kms_client(kms_config)
|
||||
kms_aes_128_encryption_plugin = KmsAes128EncryptionPlugin(self.kms_client)
|
||||
self.kms_plugins[kms_aes_128_encryption_plugin.algorithm_name()] = kms_aes_128_encryption_plugin
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from abc import ABC, abstractmethod
|
||||
from typing import Optional, List
|
||||
from typing import Optional, List, Dict
|
||||
|
||||
from v2.nacos.config.model.config import ConfigListenContext
|
||||
from v2.nacos.transport.model.rpc_request import Request
|
||||
|
@ -46,7 +46,7 @@ class ConfigQueryRequest(AbstractConfigRequest):
|
|||
class ConfigPublishRequest(AbstractConfigRequest):
|
||||
content: Optional[str]
|
||||
casMd5: Optional[str]
|
||||
additionMap: dict[str, str] = {}
|
||||
additionMap: Dict[str, str] = {}
|
||||
|
||||
def get_request_type(self):
|
||||
return "ConfigPublishRequest"
|
||||
|
|
|
@ -2,7 +2,7 @@ import asyncio
|
|||
import json
|
||||
import logging
|
||||
import os
|
||||
from typing import Callable, Optional, List
|
||||
from typing import Callable, Optional, List, Dict
|
||||
|
||||
from v2.nacos.common.client_config import ClientConfig
|
||||
from v2.nacos.common.constants import Constants
|
||||
|
@ -18,7 +18,7 @@ class ServiceInfoCache:
|
|||
def __init__(self, client_config: ClientConfig):
|
||||
self.logger = logging.getLogger(Constants.NAMING_MODULE)
|
||||
self.cache_dir = os.path.join(client_config.cache_dir, Constants.NAMING_MODULE, client_config.namespace_id)
|
||||
self.service_info_map: dict[str, Service] = {}
|
||||
self.service_info_map: Dict[str, Service] = {}
|
||||
self.update_time_map = {}
|
||||
self.lock = asyncio.Lock()
|
||||
self.sub_callback_manager = SubscribeManager()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from typing import Optional, Callable, List
|
||||
from typing import Optional, Callable, List, Dict
|
||||
from pydantic import BaseModel
|
||||
|
||||
from v2.nacos.common.constants import Constants
|
||||
|
@ -10,7 +10,7 @@ class RegisterInstanceParam(BaseModel):
|
|||
weight: float = 1.0
|
||||
enabled: bool = True
|
||||
healthy: bool = True
|
||||
metadata: dict[str, str] = {}
|
||||
metadata: Dict[str, str] = {}
|
||||
cluster_name: str = ''
|
||||
service_name: str
|
||||
group_name: str = Constants.DEFAULT_GROUP
|
||||
|
|
|
@ -94,4 +94,6 @@ class NacosServerConnector:
|
|||
async def inject_security_info(self, headers):
|
||||
if self.client_config.username and self.client_config.password:
|
||||
access_token = await self.auth_client.get_access_token(False)
|
||||
headers[Constants.ACCESS_TOKEN] = access_token
|
||||
if access_token is not None and access_token != "":
|
||||
headers[Constants.ACCESS_TOKEN] = access_token
|
||||
return
|
||||
|
|
|
@ -70,7 +70,7 @@ class RpcClient(ABC):
|
|||
def __init__(self, logger, name: str, nacos_server: NacosServerConnector):
|
||||
self.logger = logger
|
||||
self.name = name
|
||||
self.labels: dict[str, str] = {}
|
||||
self.labels: Dict[str, str] = {}
|
||||
self.current_connection = None
|
||||
self.rpc_client_status = RpcClientStatus.INITIALIZED
|
||||
self.event_chan = asyncio.Queue()
|
||||
|
@ -137,11 +137,10 @@ class RpcClient(ABC):
|
|||
self.logger.error("%s server healthy check fail, currentConnection=%s"
|
||||
, self.name, self.current_connection.get_connection_id())
|
||||
|
||||
async with self.lock:
|
||||
if self.rpc_client_status == RpcClientStatus.SHUTDOWN:
|
||||
continue
|
||||
self.rpc_client_status = RpcClientStatus.UNHEALTHY
|
||||
await self.reconnect(ReconnectContext(server_info=None, on_request_fail=False))
|
||||
if self.rpc_client_status == RpcClientStatus.SHUTDOWN:
|
||||
continue
|
||||
self.rpc_client_status = RpcClientStatus.UNHEALTHY
|
||||
await self.reconnect(ReconnectContext(server_info=None, on_request_fail=False))
|
||||
except asyncio.CancelledError:
|
||||
break
|
||||
except asyncio.CancelledError:
|
||||
|
|
Loading…
Reference in New Issue