Skip to content

Commit 6f86c7f

Browse files
authored
docs(config_center/zookeeper): align README and comments with actual code (#1094)
The sample's README and an inline comment had three inconsistencies that confused users following the docs: - Triple port: README showed `port: 20000`, but the YAML pushed to ZK in go-server/cmd/main.go uses `port: 50000`. The server actually listens on 50000, so update README to match. - DataID: README and the inline comment in main.go used `dubbo-go-samples-configcenter-zookeeper-server`, but the actual WithDataID() call and the ZK path use `dubbo-go-samples-configcenter-zookeeper-go-server` (with `-go-`). Update both docs to match the code. - Zookeeper start command: README said `docker compose up -d zookeeper`, but the repo has no compose file for it, so the command fails. Replace with a concrete `docker run` and a link to the official Zookeeper installation guide. Both README.md and README_zh.md are kept in sync. Closes #1081 Closes #1082 Closes #1084
1 parent 800e8bc commit 6f86c7f

3 files changed

Lines changed: 22 additions & 9 deletions

File tree

config_center/zookeeper/README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,17 @@
55
This example shows dubbo-go's dynamic configuration feature with Zookeeper as config-center.
66

77
## 2. How to run
8-
### Run the following commands under `repo root`:
8+
9+
### Start a Zookeeper instance
10+
11+
Make sure a Zookeeper instance is listening on `127.0.0.1:2181`. The simplest way is to start one with Docker:
912

1013
```
11-
docker compose up -d zookeeper
14+
docker run -d --name zookeeper -p 2181:2181 zookeeper:3.8
1215
```
16+
17+
Or follow the [Zookeeper installation guide](https://zookeeper.apache.org/doc/current/zookeeperStarted.html) to install it locally.
18+
1319
### Configure the configuration file into zookeeper
1420

1521
```yaml
@@ -22,7 +28,7 @@ dubbo:
2228
protocols:
2329
triple:
2430
name: tri
25-
port: 20000
31+
port: 50000
2632
provider:
2733
services:
2834
GreeterProvider:
@@ -36,7 +42,7 @@ If there is no preexisting configuration, that is fine as well, because the samp
3642
3743
```go
3844
zkOption := config_center.WithZookeeper()
39-
dataIdOption := config_center.WithDataID("dubbo-go-samples-configcenter-zookeeper-server")
45+
dataIdOption := config_center.WithDataID("dubbo-go-samples-configcenter-zookeeper-go-server")
4046
addressOption := config_center.WithAddress("127.0.0.1:2181")
4147
groupOption := config_center.WithGroup("dubbogo")
4248
ins, err := dubbo.NewInstance(

config_center/zookeeper/README_zh.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,17 @@
55
本示例演示Dubbo-Go以ZooKeeper为配置中心来实现动态配置功能
66

77
## 2. 如何运行
8-
### `仓库根目录` 目录下执行:
8+
9+
### 启动 Zookeeper 实例
10+
11+
确保有一个 Zookeeper 实例监听在 `127.0.0.1:2181`。最简单的方式是用 Docker 启动一个:
12+
913
```
10-
docker compose up -d zookeeper
14+
docker run -d --name zookeeper -p 2181:2181 zookeeper:3.8
1115
```
16+
17+
或者参考 [Zookeeper 安装文档](https://zookeeper.apache.org/doc/current/zookeeperStarted.html) 在本地安装。
18+
1219
### 把配置文件配置到zookeeper中
1320

1421
```yaml
@@ -21,7 +28,7 @@ dubbo:
2128
protocols:
2229
triple:
2330
name: tri
24-
port: 20000
31+
port: 50000
2532
provider:
2633
services:
2734
GreeterProvider:
@@ -35,7 +42,7 @@ dubbo:
3542
3643
```go
3744
zkOption := config_center.WithZookeeper()
38-
dataIdOption := config_center.WithDataID("dubbo-go-samples-configcenter-zookeeper-server")
45+
dataIdOption := config_center.WithDataID("dubbo-go-samples-configcenter-zookeeper-go-server")
3946
addressOption := config_center.WithAddress("127.0.0.1:2181")
4047
groupOption := config_center.WithGroup("dubbogo")
4148
ins, err := dubbo.NewInstance(

config_center/zookeeper/go-server/cmd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func main() {
8787
}
8888
}
8989

90-
const configCenterZKServerConfig = `## set in config center, group is 'dubbogo', dataid is 'dubbo-go-samples-configcenter-zookeeper-server', namespace is default
90+
const configCenterZKServerConfig = `## set in config center, group is 'dubbogo', dataid is 'dubbo-go-samples-configcenter-zookeeper-go-server', namespace is default
9191
dubbo:
9292
registries:
9393
demoZK:

0 commit comments

Comments
 (0)