Skip to content

Commit

Permalink
acm内容 修正、补充java仓库 (#824)
Browse files Browse the repository at this point in the history
* amc 修正、补充java仓库

* python文档中文翻译
  • Loading branch information
CZJCC authored Oct 22, 2024
1 parent 7df4747 commit 073b0c1
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 71 deletions.
14 changes: 7 additions & 7 deletions src/content/docs/next/en/manual/user/go-sdk/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ $ go get -u github.com/nacos-group/nacos-sdk-go/v2
```go
constant.ClientConfig{
TimeoutMs uint64 // 请求Nacos服务端的超时时间,默认是10000ms
NamespaceId string // ACM的命名空间Id
Endpoint string // 当使用ACM时,需要该配置. https://help.aliyun.com/document_detail/130146.html
RegionId string // ACM&KMS的regionId,用于配置中心的鉴权
AccessKey string // ACM&KMS的AccessKey,用于配置中心的鉴权
SecretKey string // ACM&KMS的SecretKey,用于配置中心的鉴权
NamespaceId string // Nacos的命名空间Id
Endpoint string // 当使用地址服务器时,需要该配置. https://help.aliyun.com/document_detail/130146.html
RegionId string // Nacos&KMS的regionId,用于配置中心的鉴权
AccessKey string // Nacos&KMS的AccessKey,用于配置中心的鉴权
SecretKey string // Nacos&KMS的SecretKey,用于配置中心的鉴权
OpenKMS bool // 是否开启kms,默认不开启,kms可以参考文档 https://help.aliyun.com/product/28933.html
// 同时DataId必须以"cipher-"作为前缀才会启动加解密逻辑
CacheDir string // 缓存service信息的目录,默认是当前运行目录
Expand Down Expand Up @@ -143,12 +143,12 @@ configClient, err := clients.NewConfigClient(
)
```

### Create client for ACM
### Create client for Nacos
https://help.aliyun.com/document_detail/130146.html

```go
cc := constant.ClientConfig{
Endpoint: "acm.aliyun.com:8080",
Endpoint: "nacos.aliyun.com:8080",
NamespaceId: "e525eafa-f7d7-4029-83d9-008937f9d468",
RegionId: "cn-shanghai",
AccessKey: "LTAI4G8KxxxxxxxxxxxxxbwZLBr",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Nacos官方目前提供并维护了Java、Golang、Python三个版本的客户

| Language | code repo | pkg repo |
| ---- | ---- | ---- |
| Java | [https://github.com/alibaba/nacos](https://github.com/alibaba/nacos)| [https://mvnrepository.com/artifact/com.alibaba.nacos/nacos-client](https://mvnrepository.com/artifact/com.alibaba.nacos/nacos-client)
| Golang | [https://github.com/nacos-group/nacos-sdk-go](https://github.com/nacos-group/nacos-sdk-go) | github.com/nacos-group/nacos-sdk-go/v2|
| Python | [https://github.com/nacos-group/nacos-sdk-python](https://github.com/nacos-group/nacos-sdk-python) |[https://pypi.org/project/nacos-sdk-python/](https://pypi.org/project/nacos-sdk-python/)|
| C++ | [https://github.com/nacos-group/nacos-sdk-cpp](https://github.com/nacos-group/nacos-sdk-cpp)|/|
Expand Down
84 changes: 42 additions & 42 deletions src/content/docs/next/zh-cn/manual/user/go-sdk/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ sidebar:


## 使用限制
支持Go>=v1.15版本
Go>=v1.15

支持Nacos>2.x版本
Nacos>2.x

## 安装
使用`go get`安装SDK:
Expand All @@ -24,36 +24,36 @@ $ go get -u github.com/nacos-group/nacos-sdk-go/v2

```go
constant.ClientConfig{
TimeoutMs uint64 // 请求Nacos服务端的超时时间,默认是10000ms
NamespaceId string // ACM的命名空间Id
Endpoint string // 当使用ACM时,需要该配置. https://help.aliyun.com/document_detail/130146.html
RegionId string // ACM&KMS的regionId,用于配置中心的鉴权
AccessKey string // ACM&KMS的AccessKey,用于配置中心的鉴权
SecretKey string // ACM&KMS的SecretKey,用于配置中心的鉴权
OpenKMS bool // 是否开启kms,默认不开启,kms可以参考文档 https://help.aliyun.com/product/28933.html
// 同时DataId必须以"cipher-"作为前缀才会启动加解密逻辑
CacheDir string // 缓存service信息的目录,默认是当前运行目录
UpdateThreadNum int // 监听service变化的并发数,默认20
NotLoadCacheAtStart bool // 在启动的时候不读取缓存在CacheDir的service信息
UpdateCacheWhenEmpty bool // 当service返回的实例列表为空时,不更新缓存,用于推空保护
Username string // Nacos服务端的API鉴权Username
Password string // Nacos服务端的API鉴权Password
LogDir string // 日志存储路径
RotateTime string // 日志轮转周期,比如:30m, 1h, 24h, 默认是24h
MaxAge int64 // 日志最大文件数,默认3
LogLevel string // 日志默认级别,值必须是:debug,info,warn,error,默认值是info
TimeoutMs uint64 // 请求Nacos服务端的超时时间,默认是10000ms
NamespaceId string // Nacos的命名空间Id
Endpoint string // 当使用地址服务器时,需要该配置. https://help.aliyun.com/document_detail/130146.html
RegionId string // Nacos&KMS的regionId,用于配置中心的鉴权
AccessKey string // Nacos&KMS的AccessKey,用于配置中心的鉴权
SecretKey string // Nacos&KMS的SecretKey,用于配置中心的鉴权
OpenKMS bool // 是否开启kms,默认不开启,kms可以参考文档 https://help.aliyun.com/product/28933.html
// 同时DataId必须以"cipher-"作为前缀才会启动加解密逻辑
CacheDir string // 缓存service信息的目录,默认是当前运行目录
UpdateThreadNum int // 监听service变化的并发数,默认20
NotLoadCacheAtStart bool // 在启动的时候不读取缓存在CacheDir的service信息
UpdateCacheWhenEmpty bool // 当service返回的实例列表为空时,不更新缓存,用于推空保护
Username string // Nacos服务端的API鉴权Username
Password string // Nacos服务端的API鉴权Password
LogDir string // 日志存储路径
RotateTime string // 日志轮转周期,比如:30m, 1h, 24h, 默认是24h
MaxAge int64 // 日志最大文件数,默认3
LogLevel string // 日志默认级别,值必须是:debug,info,warn,error,默认值是info
}
```

* ServerConfig

```go
constant.ServerConfig{
ContextPath string // Nacos的ContextPath,默认/nacos,在2.0中不需要设置
IpAddr string // Nacos的服务地址
Port uint64 // Nacos的服务端口
Scheme string // Nacos的服务地址前缀,默认http,在2.0中不需要设置
GrpcPort uint64 // Nacos的 grpc 服务端口, 默认为 服务端口+1000, 不是必填
ContextPath string // Nacos的ContextPath,默认/nacos,在2.0中不需要设置
IpAddr string // Nacos的服务地址
Port uint64 // Nacos的服务端口
Scheme string // Nacos的服务地址前缀,默认http,在2.0中不需要设置
GrpcPort uint64 // Nacos的 grpc 服务端口, 默认为 服务端口+1000, 不是必填
}
```

Expand All @@ -64,12 +64,12 @@ constant.ServerConfig{
```go
// 创建clientConfig
clientConfig := constant.ClientConfig{
NamespaceId: "e525eafa-f7d7-4029-83d9-008937f9d468", // 如果需要支持多namespace,我们可以创建多个client,它们有不同的NamespaceId。当namespace是public时,此处填空字符串。
TimeoutMs: 5000,
NotLoadCacheAtStart: true,
LogDir: "/tmp/nacos/log",
CacheDir: "/tmp/nacos/cache",
LogLevel: "debug",
NamespaceId: "e525eafa-f7d7-4029-83d9-008937f9d468", // 如果需要支持多namespace,我们可以创建多个client,它们有不同的NamespaceId。当namespace是public时,此处填空字符串。
TimeoutMs: 5000,
NotLoadCacheAtStart: true,
LogDir: "/tmp/nacos/log",
CacheDir: "/tmp/nacos/cache",
LogLevel: "debug",
}

// 创建clientConfig的另一种方式
Expand All @@ -91,9 +91,9 @@ serverConfigs := []constant.ServerConfig{
Scheme: "http",
},
{
IpAddr: "console2.nacos.io",
ContextPath: "/nacos",
Port: 80,
IpAddr: "console2.nacos.io",
ContextPath: "/nacos",
Port: 80,
Scheme: "http",
},
}
Expand All @@ -116,14 +116,14 @@ serverConfigs := []constant.ServerConfig{

// 创建服务发现客户端
_, _ := clients.CreateNamingClient(map[string]interface{}{
"serverConfigs": serverConfigs,
"clientConfig": clientConfig,
"serverConfigs": serverConfigs,
"clientConfig": clientConfig,
})

// 创建动态配置客户端
_, _ := clients.CreateConfigClient(map[string]interface{}{
"serverConfigs": serverConfigs,
"clientConfig": clientConfig,
"serverConfigs": serverConfigs,
"clientConfig": clientConfig,
})

// 创建服务发现客户端的另一种方式 (推荐)
Expand All @@ -143,12 +143,12 @@ configClient, err := clients.NewConfigClient(
)
```

### Create client for ACM
### Create client for Nacos
https://help.aliyun.com/document_detail/130146.html

```go
cc := constant.ClientConfig{
Endpoint: "acm.aliyun.com:8080",
Endpoint: "nacos.aliyun.com:8080",
NamespaceId: "e525eafa-f7d7-4029-83d9-008937f9d468",
RegionId: "cn-shanghai",
AccessKey: "LTAI4G8KxxxxxxxxxxxxxbwZLBr",
Expand Down Expand Up @@ -292,7 +292,7 @@ serviceInfos, err := namingClient.GetAllServicesInfo(vo.GetAllServiceInfoParam{
NameSpace: "0e83cc81-9d8c-4bb8-a28a-ff703187543f",
PageNo: 1,
PageSize: 10,
}),
}),

```

Expand Down Expand Up @@ -338,7 +338,7 @@ err := configClient.ListenConfig(vo.ConfigParam{
Group: "group",
OnChange: func(namespace, group, dataId, data string) {
fmt.Println("group:" + group + ", dataId:" + dataId + ", data:" + data)
},
},
})

```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Nacos官方目前提供并维护了Java、Golang、Python三个版本的客户

| 编程语言 | 代码仓库 | 包仓库 |
| ---- | ---- | ---- |
| Java | [https://github.com/alibaba/nacos](https://github.com/alibaba/nacos)| [https://mvnrepository.com/artifact/com.alibaba.nacos/nacos-client](https://mvnrepository.com/artifact/com.alibaba.nacos/nacos-client)
| Golang | [https://github.com/nacos-group/nacos-sdk-go](https://github.com/nacos-group/nacos-sdk-go) | github.com/nacos-group/nacos-sdk-go/v2|
| Python | [https://github.com/nacos-group/nacos-sdk-python](https://github.com/nacos-group/nacos-sdk-python) |[https://pypi.org/project/nacos-sdk-python/](https://pypi.org/project/nacos-sdk-python/)|
| C++ | [https://github.com/nacos-group/nacos-sdk-cpp](https://github.com/nacos-group/nacos-sdk-cpp)|/|
Expand Down
44 changes: 22 additions & 22 deletions src/content/docs/next/zh-cn/manual/user/python-sdk/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ sidebar:
# Python SDK 使用手册


### 支持 Python version:
### 支持 Python 版本

- Python 2.7
- Python 3.6+

### Supported Nacos version
### 支持 Nacos 服务端版本
- Nacos 0.8.0+
- Nacos 1.x
- Nacos 2.x with http protocol


## Installation
## 安装依赖
```shell
pip install nacos-sdk-python
```

## Getting Started
## 开始
```python
import nacos

Expand All @@ -45,7 +45,7 @@ group = "group"
print(client.get_config(data_id, group))
```

## Configuration
## 客户端配置
```
client = NacosClient(server_addresses, namespace=your_ns, ak=your_ak, sk=your_sk)
```
Expand All @@ -57,7 +57,7 @@ client = NacosClient(server_addresses, namespace=your_ns, ak=your_ak, sk=your_sk
* *log_level* - Log level. | default: null
* *log_rotation_backup_count* - The number of log files to keep. | default: `7`

#### Extra Options
#### 额外配置
Extra option can be set by `set_options`, as following:

```
Expand All @@ -76,9 +76,9 @@ Configurable options are:
* *no_snapshot* - To disable default snapshot behavior, this can be overridden by param *no_snapshot* in *get* method.
* *proxies* - Dict proxy mapping, some environments require proxy access, so you can set this parameter, this way http requests go through the proxy.

## API Reference
## API 列表

### Get Config
### 获取配置
>`NacosClient.get_config(data_id, group, timeout, no_snapshot)`
* `param` *data_id* Data id.
Expand All @@ -98,7 +98,7 @@ Get value of one config item following priority:

* Step 3 - Get from snapshot dir.

### Add Watchers
### 增加配置监听
>`NacosClient.add_config_watchers(data_id, group, cb_list)`
* `param` *data_id* Data id.
Expand All @@ -112,7 +112,7 @@ Add watchers to a specified config item.
* Multiple callbacks on one item is allowed and all callback functions are invoked concurrently by `threading.Thread`.
* Callback functions are invoked from current process.

### Remove Watcher
### 移除配置监听
>`NacosClient.remove_config_watcher(data_id, group, cb, remove_all)`
* `param` *data_id* Data id.
Expand All @@ -123,7 +123,7 @@ Add watchers to a specified config item.

Remove watcher from specified key.

### Publish Config
### 发布配置
>`NacosClient.publish_config(data_id, group, content, timeout)`
* `param` *data_id* Data id.
Expand All @@ -137,7 +137,7 @@ Publish one data item to Nacos.
* If the data key is exist, update to the content specified.
* Content can not be set to None, if there is need to delete config item, use function **remove** instead.

### Remove Config
### 删除配置
>`NacosClient.remove_config(data_id, group, timeout)`
* `param` *data_id* Data id.
* `param` *group* Group, use "DEFAULT_GROUP" if no group specified.
Expand All @@ -146,7 +146,7 @@ Publish one data item to Nacos.

Remove one data item from Nacos.

### Register Instance
### 服务实例注册
>`NacosClient.add_naming_instance(service_name, ip, port, cluster_name, weight, metadata, enable, healthy,ephemeral,group_name,heartbeat_interval)`
* `param` *service_name* **required** Service name to register to.
* `param` *ip* **required** IP of the instance.
Expand All @@ -160,7 +160,7 @@ Remove one data item from Nacos.
* `param` *heartbeat_interval* Auto daemon heartbeat interval in seconds.
* `return` True if success or an exception will be raised.

### Deregister Instance
### 服务实例取消注册
>`NacosClient.remove_naming_instance(service_name, ip, port, cluster_name)`
* `param` *service_name* **required** Service name to deregister from.
* `param` *ip* **required** IP of the instance.
Expand All @@ -169,7 +169,7 @@ Remove one data item from Nacos.
* `param` *ephemeral* A bool value to determine whether instance is ephemeral or not.
* `return` True if success or an exception will be raised.

### Modify Instance
### 修改服务实例
>`NacosClient.modify_naming_instance(service_name, ip, port, cluster_name, weight, metadata, enable)`
* `param` *service_name* **required** Service name.
* `param` *ip* **required** IP of the instance.
Expand All @@ -181,7 +181,7 @@ Remove one data item from Nacos.
* `param` *ephemeral* A bool value to determine whether instance is ephemeral or not.
* `return` True if success or an exception will be raised.

### Query Instances
### 查询服务实例列表
>`NacosClient.list_naming_instance(service_name, clusters, namespace_id, group_name, healthy_only)`
* `param` *service_name* **required** Service name to query.
* `param` *clusters* Cluster names separated by comma.
Expand All @@ -190,15 +190,15 @@ Remove one data item from Nacos.
* `param` *healthy_only* A bool value for querying healthy instances or not.
* `return` Instance info list if success or an exception will be raised.

### Query Instance Detail
### 查询服务实例详情
>`NacosClient.get_naming_instance(service_name, ip, port, cluster_name)`
* `param` *service_name* **required** Service name.
* `param` *ip* **required** IP of the instance.
* `param` *port* **required** Port of the instance.
* `param` *cluster_name* Cluster name.
* `return` Instance info if success or an exception will be raised.

### Send Instance Beat
### 主动发送心跳
>`NacosClient.send_heartbeat(service_name, ip, port, cluster_name, weight, metadata)`
* `param` *service_name* **required** Service name.
* `param` *ip* **required** IP of the instance.
Expand All @@ -209,7 +209,7 @@ Remove one data item from Nacos.
* `param` *metadata* Extra info in JSON string format or dict format.
* `return` A JSON object include server recommended beat interval if success or an exception will be raised.

### Subscribe Service Instances Changed
### 服务实例监听
>`NacosClient.subscribe(listener_fn, listener_interval=7, *args, **kwargs)`
* `param` *listener_fn* **required** Customized listener function.
* `param` *listener_interval* Listen interval , default 7 second.
Expand All @@ -220,17 +220,17 @@ Remove one data item from Nacos.
* `param` *healthy_only* A bool value for querying healthy instances or not.
* `return`

### Unsubscribe Service Instances Changed
### 服务实例取消监听
>`NacosClient.unsubscribe(service_name, listener_name)`
* `param` *service_name* **required** Service name to subscribed.
* `param` *listener_name* listener_name which is customized.
* `return`

### Stop All Service Subscribe
### 停止所有服务监听
>`NacosClient.stop_subscribe()`
* `return`

## Debugging Mode
## 调试模式
Debugging mode if useful for getting more detailed log on console.

Debugging mode can be set by:
Expand Down

0 comments on commit 073b0c1

Please sign in to comment.