FinalT commented on code in PR #711:
URL: https://github.com/apache/dubbo-go-samples/pull/711#discussion_r1519722488


##########
config_yaml/README.md:
##########
@@ -0,0 +1,232 @@
+# Dubbo-go Config_Yaml
+
+## 1.Introduction
+
+This example demonstrates how to configure using yaml configuration files in 
Dubbo-go framework
+
+## 2.Run
+```txt
+.
+├── go-client
+│   ├── cmd
+│   │   └── main.go
+│   └── conf
+│       └── dubbogo.yml
+├── go-server
+│   ├── cmd
+│   │   └── main.go
+│   └── conf
+│       └── dubbogo.yml
+└─── proto
+    ├── greet.pb.go
+    ├── greet.proto
+    └── greet.triple.go
+
+```
+通过 IDL`./proto/greet.proto` 定义服务 使用triple协议
+
+### build Proto
+```bash
+cd path_to_dubbogo-sample/config_yaml/proto
+protoc --go_out=. --go-triple_out=. ./greet.proto
+```
+### Server
+```bash
+export DUBBO_GO_CONFIG_PATH="../conf/dubbogo.yml"
+cd path_to_dubbogo-sample/config_yaml/go-server/cmd
+go run .
+```
+### Client
+```bash
+export DUBBO_GO_CONFIG_PATH="../conf/dubbogo.yml"
+cd path_to_dubbogo-sample/config_yaml/go-client/cmd
+go run .
+```
+
+### 2.1 Client usage instructions
+
+Client-defined yaml file
+```yaml
+# dubbo client yaml configure file
+dubbo:
+  registries:
+    demoZK:
+      protocol: zookeeper
+      timeout: 3s
+      address: 127.0.0.1:2181
+  consumer:
+    references:
+      GreetServiceImpl:
+        protocol: tri
+        interface: com.apache.dubbo.sample.Greeter
+        registry: demoZK
+        retries: 3
+        timeout: 3000
+```
+Read and load files through dubbo.Load() calls
+
+```go
+//...
+func main() {
+       //...
+       if err := dubbo.Load(); err != nil {
+               //...
+       }
+       //...
+}
+```
+
+### 2.2 Server usage instructions
+
+Yaml file defined on the server side
+
+```yaml
+# dubbo server yaml configure file
+dubbo:
+  registries:
+    demoZK:
+      protocol: zookeeper
+      timeout: 10s
+      address: 127.0.0.1:2181
+  protocols:
+    tripleProtocol:
+      name: tri
+      port: 20000
+  provider:
+    services:
+      GreetTripleServer:
+        interface: com.apache.dubbo.sample.Greeter
+```
+
+Read and load files through dubbo.Load() calls
+```go
+//...
+func main() {
+       //...
+       if err := dubbo.Load(); err != nil {
+               //...
+       }
+       //...
+}
+```
+## 3.Example
+
+### 3.1 Server 
+
+#### IDL
+
+Source file path :dubbo-go-sample/context/proto/greet.proto
+
+```protobuf
+syntax = "proto3";
+
+package greet;
+
+option go_package = 
"github.com/apache/dubbo-go-samples/config_yaml/proto;greet";
+
+message GreetRequest {
+  string name = 1;
+}
+
+message GreetResponse {
+  string greeting = 1;
+}
+
+service GreetService {
+  rpc Greet(GreetRequest) returns (GreetResponse) {}
+}
+```
+
+#### Server Handler
+
+On the server side, define GreetTripleServer interface:
+```go
+type GreetServiceHandler interface {
+    Greet(context.Context, *GreetRequest) (*GreetResponse, error)
+}
+```
+Implement the GreetServiceHandler interface and register through 
`greet.SetProviderService(&GreetTripleServer{})`  
+Also use `dubbo.Load()` to load the configuration file
+
+Source file path :dubbo-go-sample/config_yaml/go-server/cmd/main.go
+
+```go
+
+package main
+
+import (
+       "context"
+       "dubbo.apache.org/dubbo-go/v3"
+       _ "dubbo.apache.org/dubbo-go/v3/imports"
+       "errors"
+       "fmt"
+
+       greet "github.com/apache/dubbo-go-samples/config_yaml/proto"

Review Comment:
   plz format imports..



##########
config_yaml/README_zh.md:
##########
@@ -0,0 +1,233 @@
+# Dubbo-go Config_Yaml
+
+## 1.介绍
+
+本示例演示如何在Dubbo-go框架中使用yaml配置文件进行配置
+
+## 2.使用说明
+```txt
+.
+├── go-client
+│   ├── cmd
+│   │   └── main.go
+│   └── conf
+│       └── dubbogo.yml
+├── go-server
+│   ├── cmd
+│   │   └── main.go
+│   └── conf
+│       └── dubbogo.yml
+└─── proto
+    ├── greet.pb.go
+    ├── greet.proto
+    └── greet.triple.go
+
+```
+通过 IDL`./proto/greet.proto` 定义服务 使用triple协议
+
+
+### build Proto
+```bash
+cd path_to_dubbogo-sample/config_yaml/proto
+protoc --go_out=. --go-triple_out=. ./greet.proto
+```
+### Server
+```bash
+export DUBBO_GO_CONFIG_PATH="../conf/dubbogo.yml"
+cd path_to_dubbogo-sample/config_yaml/go-server/cmd
+go run .
+```
+### Client
+```bash
+export DUBBO_GO_CONFIG_PATH="../conf/dubbogo.yml"
+cd path_to_dubbogo-sample/config_yaml/go-client/cmd
+go run .
+```
+
+### 2.1客户端使用说明
+
+客户端定义的yaml文件
+```yaml
+# dubbo client yaml configure file
+dubbo:
+  registries:
+    demoZK:
+      protocol: zookeeper
+      timeout: 3s
+      address: 127.0.0.1:2181
+  consumer:
+    references:
+      GreetServiceImpl:
+        protocol: tri
+        interface: com.apache.dubbo.sample.Greeter
+        registry: demoZK
+        retries: 3
+        timeout: 3000
+```
+通过dubbo.Load()调用进行文件的读取以及加载
+```go
+//...
+func main() {
+       //...
+       if err := dubbo.Load(); err != nil {
+               //...
+       }
+       //...
+}
+```
+
+### 2.2服务端使用说明
+
+服务端定义的yaml文件
+```yaml
+# dubbo server yaml configure file
+dubbo:
+  registries:
+    demoZK:
+      protocol: zookeeper
+      timeout: 10s
+      address: 127.0.0.1:2181
+  protocols:
+    tripleProtocol:
+      name: tri
+      port: 20000
+  provider:
+    services:
+      GreetTripleServer:
+        interface: com.apache.dubbo.sample.Greeter
+```
+通过dubbo.Load()调用进行文件的读取以及加载
+```go
+//...
+func main() {
+       //...
+       if err := dubbo.Load(); err != nil {
+               //...
+       }
+       //...
+}
+
+```
+## 3.案例
+
+### 3.1服务端介绍
+
+#### 服务端proto文件
+
+源文件路径:dubbo-go-sample/context/proto/greet.proto
+
+```protobuf
+syntax = "proto3";
+
+package greet;
+
+option go_package = 
"github.com/apache/dubbo-go-samples/config_yaml/proto;greet";
+
+message GreetRequest {
+  string name = 1;
+}
+
+message GreetResponse {
+  string greeting = 1;
+}
+
+service GreetService {
+  rpc Greet(GreetRequest) returns (GreetResponse) {}
+}
+```
+
+#### 服务端handler文件
+
+在服务端中,定义GreetTripleServer:
+```go
+type GreetServiceHandler interface {
+    Greet(context.Context, *GreetRequest) (*GreetResponse, error)
+}
+```
+实现GreetServiceHandler接口,通过`greet.SetProviderService(&GreetTripleServer{})`进行注册 
 
+同样使用`dubbo.Load()`进行加载配置文件
+
+
+源文件路径:dubbo-go-sample/config_yaml/go-server/cmd/main.go
+
+```go
+
+package main
+
+import (
+       "context"
+       "dubbo.apache.org/dubbo-go/v3"
+       _ "dubbo.apache.org/dubbo-go/v3/imports"
+       "errors"
+       "fmt"
+
+       greet "github.com/apache/dubbo-go-samples/config_yaml/proto"

Review Comment:
   ditto.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to