Skip to content

Commit

Permalink
docs: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
li-jin-gou committed Dec 15, 2023
1 parent bf195a6 commit 0dc3fef
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Nacos"
linkTitle: "Nacos"
title: "nacos"
linkTitle: "nacos"
date: 2023-12-14
weight: 4
keywords: ["ConfigCenter Extension","Nacos"]
Expand All @@ -10,11 +10,11 @@ description: "Use Nacos as Kitex’s service governance configuration center"
### Install
`go get github.com/kitex-contrib/config-nacos`

### Suite
## Suite
The configuration center adapter of Nacos.


#### Server
### Server

```go
type NacosServerSuite struct {
Expand Down Expand Up @@ -77,7 +77,7 @@ func main() {
}
```

#### Client
### Client

```go
type NacosClientSuite struct {
Expand Down Expand Up @@ -150,7 +150,7 @@ func main() {
}
```

#### SetParser
### SetParser

Set a custom parser for deserializing configuration, support json yaml default. User could extend it by self.

Expand Down Expand Up @@ -203,17 +203,17 @@ func main() {
}
```

### Nacos Configuration
## Nacos Configuration

The client is initialized according to the parameters of `Options` and connects to the nacos server. After the connection is established, the suite subscribes the appropriate configuration based on `Group`, `ServerDataIDFormat` and `ClientDataIDFormat` to updates its own policy dynamically. See the `Options` variables below for specific parameters.

The configuration format supports `json` and `yaml`. You can use the [SetParser](https://github.com/kitex-contrib/config-nacos/blob/eb006978517678dd75a81513142d3faed6a66f8d/nacos/nacos.go#L68) function to customise the format parsing method, and the `CustomFunction` function to customise the format of the subscription function during `NewSuite`.

#### CustomFunction
### CustomFunction

Provide the mechanism to custom the nacos parameter `vo.ConfigParam`.

#### Options Variable
### Options Variable

| Variable Name | Default Value | Introduction |
| ------------------------- | ---------------------------------- | --------------------------------- |
Expand All @@ -224,10 +224,10 @@ Provide the mechanism to custom the nacos parameter `vo.ConfigParam`.
| ServerDataIDFormat | {{.ServerServiceName}}.{{.Category}} | Use go [template](https://pkg.go.dev/text/template) syntax rendering to generate the appropriate ID, and use `ServiceName` `Category` two metadatas that can be customised |
| Group | DEFAULT_GROUP | Use fixed values or dynamic rendering. Usage is the same as configDataId. |

#### Governance Policy
### Governance Policy
> The configDataId and configGroup in the following example use default values, the service name is `ServiceName` and the client name is `ClientName`.
##### Rate Limit
#### Rate Limit
Category=limit
> Currently, current limiting only supports the server side, so ClientServiceName is empty.
Expand Down Expand Up @@ -255,7 +255,7 @@ Note:
- Not configured or value is 0 means not enabled.
- connection_limit and qps_limit can be configured independently, e.g. connection_limit = 100, qps_limit = 0

##### Retry Policy
#### Retry Policy
Category=retry
[JSON Schema](https://github.com/cloudwego/kitex/blob/develop/pkg/retry/policy.go#L63)

Expand Down Expand Up @@ -309,7 +309,7 @@ Example:
```
Note: retry.Container has built-in support for specifying the default configuration using the `*` wildcard (see the [getRetryer](https://github.com/cloudwego/kitex/blob/v0.5.1/pkg/retry/retryer.go#L240) method for details).

##### RPC Timeout
#### RPC Timeout
Category=rpc_timeout

[JSON Schema](https://github.com/cloudwego/kitex/blob/develop/pkg/rpctimeout/item_rpc_timeout.go#L42)
Expand All @@ -332,7 +332,7 @@ Example:
```
Note: The circuit breaker implementation of kitex does not currently support changing the global default configuration (see [initServiceCB](https://github.com/cloudwego/kitex/blob/v0.5.1/pkg/circuitbreak/cbsuite.go#L195) for details).

##### Circuit Break
#### Circuit Break
Category=circuit_break

[JSON Schema](https://github.com/cloudwego/kitex/blob/develop/pkg/circuitbreak/item_circuit_breaker.go#L30)
Expand All @@ -357,7 +357,7 @@ The echo method uses the following configuration (0.3, 100) and other methods us
}
```

### Note
## Note
Do not delete the config in nacos, otherwise the nacos sdk may produce a large warning log.


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Nacos"
linkTitle: "Nacos"
title: "nacos"
linkTitle: "nacos"
date: 2023-12-14
weight: 4
keywords: ["配置中心扩展","Nacos"]
Expand Down Expand Up @@ -203,17 +203,17 @@ func main() {
}
```

### Nacos 配置
## Nacos 配置

根据 Options 的参数初始化 client,建立链接之后 suite 会根据 `Group` 以及 `ServerDataIDFormat` 或者 `ClientDataIDFormat` 订阅对应的配置并动态更新自身策略,具体参数参考下面 `Options` 变量。

配置的格式默认支持 `json``yaml`,可以使用函数 [SetParser](https://github.com/kitex-contrib/config-nacos/blob/eb006978517678dd75a81513142d3faed6a66f8d/nacos/nacos.go#L68) 进行自定义格式解析方式,并在 `NewSuite` 的时候使用 `CustomFunction` 函数修改订阅函数的格式。

#### CustomFunction
### CustomFunction

允许用户自定义 nacos 的参数。

#### Options 默认值
### Options 默认值

| 参数 | 变量默认值 | 作用 |
| ------------------------- | ---------------------------------- | --------------------------------- |
Expand All @@ -224,11 +224,11 @@ func main() {
| ServerDataIDFormat | {{.ServerServiceName}}.{{.Category}} | 使用 go [template](https://pkg.go.dev/text/template) 语法渲染生成对应的 ID, 使用 `ServiceName` `Category` 两个元数据 |
| Group | DEFAULT_GROUP | 使用固定值,也可以动态渲染,用法同 DataIDFormat |

#### 治理策略
### 治理策略

下面例子中的 configDataId 以及 configGroup 均使用默认值,服务名称为 ServiceName,客户端名称为 ClientName

##### 限流
#### 限流
Category=limit
> 限流目前只支持服务端,所以 ClientServiceName 为空。
Expand All @@ -255,7 +255,7 @@ Category=limit
- 「未配置」或「取值为 0」表示不开启
- connection_limit 和 qps_limit 可以独立配置,例如 connection_limit = 100, qps_limit = 0

##### 重试
#### 重试
Category=retry

[JSON Schema](https://github.com/cloudwego/kitex/blob/develop/pkg/retry/policy.go#L63)
Expand Down Expand Up @@ -310,7 +310,7 @@ Category=retry
```
注:retry.Container 内置支持用 * 通配符指定默认配置(详见 [getRetryer](https://github.com/cloudwego/kitex/blob/v0.5.1/pkg/retry/retryer.go#L240) 方法)

##### 超时
#### 超时
Category=rpc_timeout

[JSON Schema](https://github.com/cloudwego/kitex/blob/develop/pkg/rpctimeout/item_rpc_timeout.go#L42)
Expand All @@ -333,7 +333,7 @@ Category=rpc_timeout
```
注:kitex 的熔断实现目前不支持修改全局默认配置(详见 [initServiceCB](https://github.com/cloudwego/kitex/blob/v0.5.1/pkg/circuitbreak/cbsuite.go#L195)

##### 熔断:
#### 熔断:
Category=circuit_break

[JSON Schema](https://github.com/cloudwego/kitex/blob/develop/pkg/circuitbreak/item_circuit_breaker.go#L30)
Expand All @@ -358,7 +358,7 @@ echo 方法使用下面的配置(0.3、100),其他方法使用全局默认
}
```

### 备注
## 注意
在启动后不要删除 Nacos 上的配置信息,不然会产生大量的警告日志

## 兼容性
Expand Down

0 comments on commit 0dc3fef

Please sign in to comment.