This is an automated email from the ASF dual-hosted git repository.
alexstocks pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-go-samples.git
The following commit(s) were added to refs/heads/master by this push:
new 1bce8620 add application-level service discovery generic call's README
(#489)
1bce8620 is described below
commit 1bce8620cbeef78a150fc86b6eec66dcbc3ea159
Author: Leo Shen <[email protected]>
AuthorDate: Fri Feb 3 21:32:16 2023 +0800
add application-level service discovery generic call's README (#489)
* add application-level service discovery generic call's README
* format README
* format README
* add blank lines
---
generic/README.md | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
generic/README_zh.md | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 104 insertions(+)
diff --git a/generic/README.md b/generic/README.md
index 1d548d8a..c69e1112 100644
--- a/generic/README.md
+++ b/generic/README.md
@@ -50,3 +50,55 @@ Using command line tool. The `$ProjectRootDir` is the root
directory of the dubb
cd $ProjectRootDir/generic/default/go-client/cmd \
&& go run client.go
```
+
+## Switch the example from interface-level service discovery to
application-level service discovery
+
+1. Modify the configuration file of the server go-server and add the field
`registry-type: service`
+
+```
+registries:
+ zk:
+ protocol: zookeeper
+ timeout: 3s
+ address: 127.0.0.1:2181
+ registry-type: service
+...
+...
+```
+
+2. Modify the client.go file of client go-client
+
+First add the field `RegistryType: "service"`:
+
+```
+registryConfig := &config.RegistryConfig{
+ Protocol: "zookeeper",
+ Address: "127.0.0.1:2181",
+ RegistryType: "service",
+}
+```
+
+Then add `metadataConfig` configuration:
+
+```
+metadataConf := &config.MetadataReportConfig{
+ Protocol: "zookeeper",
+ Address: "127.0.0.1:2181",
+}
+```
+
+Finally, configure `metadataConfig` into `rootConfig` through
`SetMetadataReport`
+
+```
+...
+...
+rootConfig := config. NewRootConfigBuilder().
+ AddRegistry("zk", registryConfig).
+ SetMetadataReport(metadataConf).
+ build()
+...
+...
+```
+
+Now, the generic call of application-level service discovery can be realized.
+
diff --git a/generic/README_zh.md b/generic/README_zh.md
index 4ec20b06..07ea42ba 100644
--- a/generic/README_zh.md
+++ b/generic/README_zh.md
@@ -50,3 +50,55 @@ cd $ProjectRootDir/generic/default/go-server/cmd \
cd $ProjectRootDir/generic/default/go-client/cmd \
&& go run client.go
```
+
+## 将示例由接口级服务发现切换至应用级服务发现
+
+1. 修改服务端 go-server 的配置文件,增添字段 `registry-type: service`
+
+```
+registries:
+ zk:
+ protocol: zookeeper
+ timeout: 3s
+ address: 127.0.0.1:2181
+ registry-type: service
+...
+...
+```
+
+2. 修改客户端 go-client 的 client.go 文件
+
+首先添加同样添加 `RegistryType: "service"` 字段
+
+```
+registryConfig := &config.RegistryConfig{
+ Protocol: "zookeeper",
+ Address: "127.0.0.1:2181",
+ RegistryType: "service",
+}
+```
+
+然后增添 `metadataConfig` 配置
+
+```
+metadataConf := &config.MetadataReportConfig{
+ Protocol: "zookeeper",
+ Address: "127.0.0.1:2181",
+}
+```
+
+最后将 `metadataConfig` 通过 `SetMetadataReport` 配置进入 `rootConfig`
+
+```
+...
+...
+rootConfig := config.NewRootConfigBuilder().
+ AddRegistry("zk", registryConfig).
+ SetMetadataReport(metadataConf).
+ Build()
+...
+...
+```
+
+至此即可实现应用级服务发现的泛化调用。
+