Package: nacos-sdk-rust-binding-py
nacos-sdk-rust-binding-pynacos-sdk-rust binding for Python with PyO3.Tip: nacos-sdk-python 仓库暂未提供 2.x gRPC 交互模式，为了能升级它，故而通过 ffi 方式调用 nacos-sdk-rustInstallationpipinstallnacos-sdk-rust-binding-pyproject package seehttps://pypi.org/project/nacos-sdk-rust-binding-pyUsage使用样例请看仓库内的 examples 目录环境变量NACOS_CLIENT_LOGGER_LEVEL=INFO可设置日志打印级别，默认 INFO客户端日志请在目录$HOME/logs/nacos/查看环境变量NACOS_CLIENT_COMMON_THREAD_CORES=4可设置客户端核心线程数，默认是 CPU 数目 1环境变量ENV_NACOS_CLIENT_NAMING_PUSH_EMPTY_PROTECTION=false可关闭 Naming 防推空保护，默认 true更多环境变量请看nacos-sdk-rust的文档说明Definition of ClientOptionsclassClientOptions:# Server Addr, e.g. address:port[,address:port],...]#[pyo3(set, get)]server_addr:String,# Namespace/Tenant#[pyo3(set, get)]namespace:String,# AppName#[pyo3(set, get)]app_name:Option<String>,# Username for Auth#[pyo3(set, get)]username:Option<String>,# Password for Auth#[pyo3(set, get)]password:Option<String>,# naming push_empty_protection, default true#[pyo3(set, get)]naming_push_empty_protection:Option<bool>,# Initdef__init__(self,server_addr,namespace,app_name,username,password):self.server_addr=server_addrself.server_addr=namespaceself.app_name=app_nameself.username=usernameself.password=passwordDefinition of ConfigclassNacosConfigResponse:# Namespace/Tenant# [pyo3(get)]namespace:String,# DataId# [pyo3(get)]data_id:String,# Group# [pyo3(get)]group:String,# Content# [pyo3(get)]content:String,# Content's Type; e.g. json,properties,xml,html,text,yaml# [pyo3(get)]content_type:String,# Content's md5# [pyo3(get)]md5:String,classNacosConfigClient:# Init. If it fails, pay attention to errdef__init__(self,client_options:ClientOptions):# inner logic xxxpass# Get config's content. If it fails, pay attention to errdefget_config(self,data_id:String,group:String)->String:pass# Get NacosConfigResponse. If it fails, pay attention to errdefget_config_resp(self,data_id:String,group:String)->NacosConfigResponse:pass# Publish config. If it fails, pay attention to errdefpublish_config(self,data_id:String,group:String,content:String)->bool:pass# Remove config. If it fails, pay attention to errdefremove_config(self,data_id:String,group:String)->bool:pass# Add NacosConfigChangeListener callback func, which listen the config change. If it fails, pay attention to errdefadd_listener(self,data_id:String,group:String,listener:py_function):passDefinition of NamingclassNacosServiceInstance:# Instance Id#[pyo3(set, get)]instance_id:Option<String>,# Ip#[pyo3(set, get)]ip:String,# Port#[pyo3(set, get)]port:i32,# Weight, default 1.0#[pyo3(set, get)]weight:Option<f64>,# Healthy or not, default true#[pyo3(set, get)]healthy:Option<bool>,# Enabled ot not, default true#[pyo3(set, get)]enabled:Option<bool>,# Ephemeral or not, default true#[pyo3(set, get)]ephemeral:Option<bool>,# Cluster Name, default 'DEFAULT'#[pyo3(set, get)]cluster_name:Option<String>,# Service Name#[pyo3(set, get)]service_name:Option<String>,# Metadata, default '{}'#[pyo3(set, get)]metadata:Option<std::collections::HashMap<String,String>>,# Initdef__init__(self,ip,port,weight,healthy,enabled,ephemeral,cluster_name,service_name,metadata):# inner logic xxxpassclassNacosNamingClient:# Init. If it fails, pay attention to errdef__init__(self,client_options:ClientOptions):# inner logic xxxpass# Register instance. If it fails, pay attention to errdefregister_instance(self,service_name:String,group:String,service_instance:NacosServiceInstance):pass# Deregister instance. If it fails, pay attention to errdefderegister_instance(self,service_name:String,group:String,service_instance:NacosServiceInstance):pass# Batch register instance, improve interaction efficiency. If it fails, pay attention to errdefbatch_register_instance(self,service_name:String,group:String,service_instances:[NacosServiceInstance]):pass# Get all instances by service and group. default cluster=[], subscribe=true. If it fails, pay attention to errdefget_all_instances(self,service_name:String,group:String,clusters:Option<[String]>,subscribe:Option<bool>)->[NacosServiceInstance]:pass# Select instances whether healthy or not. default cluster=[], subscribe=true, healthy=true. If it fails, pay attention to errdefselect_instances(self,service_name:String,group:String,clusters:Option<[String]>,subscribe:Option<bool>,healthy:Option<bool>)->[NacosServiceInstance]:pass# Select one healthy instance. default cluster=[], subscribe=true. If it fails, pay attention to errdefselect_one_healthy_instance(self,service_name:String,group:String,clusters:Option<[String]>,subscribe:Option<bool>)->NacosServiceInstance:pass# Add NacosNamingEventListener callback func, which listen the instance change. If it fails, pay attention to errdefsubscribe(self,service_name:String,group:String,clusters:Option<[String]>,listener:py_function)->NacosServiceInstance:passDevelopmentSetup virtualenv:python-mvenvvenvActivate venv:sourcevenv/bin/activateInstallmaturin:pipinstallmaturin[patchelf]Build bindings:maturindevelopRun some tests:maturindevelop-EtestbehavetestsBuild API docs:maturindevelop-Edocs
pdocnacos-sdk-rust-binding-pyLicenseApache License Version 2.0Acknowledgementbinding for Python withPyO3binding thenacos-sdk-rust