AlexStocks commented on a change in pull request #52:
URL: https://github.com/apache/dubbo-go-samples/pull/52#discussion_r587586108



##########
File path: helloworld/README_zh.md
##########
@@ -0,0 +1,135 @@
+## Hello World 实例
+
+### 配置
+
+注册中心配置
+
+```yaml
+# registry config
+registries:
+  "demoZk":
+    protocol: "zookeeper"
+    timeout: "3s"
+    address: "127.0.0.1:2181"
+
+```
+
+服务提供者配置
+
+```yaml
+# service config
+services:
+  # Reference ID
+  "UserProvider":
+    registry: "demoZk"
+    protocol: "dubbo"
+    interface: "org.apache.dubbo.UserProvider"
+    cluster: "failover"
+    methods:
+      - name: "GetUser"
+        retries: 1
+```
+
+服务消费者配置
+
+```yaml
+# reference config
+references:
+  # Reference ID
+  "UserProvider":
+    registry: "demoZk"
+    protocol: "dubbo"
+    interface: "org.apache.dubbo.UserProvider"
+    cluster: "failover"
+    methods:
+      - name: "GetUser"
+        retries: 3
+```
+
+### 代码示例
+
+生产者示例
+
+```go
+// init 
+func init() {
+       config.SetProviderService(new(UserProvider))
+       // ------for hessian2------
+       hessian.RegisterPOJO(&User{})
+}
+
+// define dto
+type User struct {
+       Id   string
+       Name string
+       Age  int32
+       Time time.Time
+}
+
+// implement POJO interface for hessian2
+func (u User) JavaClassName() string {
+       return "org.apache.dubbo.User"
+}
+
+// service define
+type UserProvider struct {
+}
+
+// interface define
+func (u *UserProvider) GetUser(ctx context.Context, req []interface{}) (*User, 
error) {
+       //biz code...
+}
+
+// implement RPCService interface
+func (u *UserProvider) Reference() string {
+       return "UserProvider"
+}
+```
+
+消费者示例
+
+```go
+var userProvider = new(pkg.UserProvider)
+
+// init 
+func init() {
+       config.SetConsumerService(userProvider)
+       hessian.RegisterPOJO(&pkg.User{})
+}
+
+// define dto
+type User struct {
+       Id   string

Review comment:
       Id -> ID




----------------------------------------------------------------
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.

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