You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/04/24 02:26:06 UTC

[GitHub] [dubbo-go-samples] cjphaha opened a new pull request #97: add readme of game

cjphaha opened a new pull request #97:
URL: https://github.com/apache/dubbo-go-samples/pull/97


   


-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-samples] AlexStocks commented on a change in pull request #97: add readme of game

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on a change in pull request #97:
URL: https://github.com/apache/dubbo-go-samples/pull/97#discussion_r619729653



##########
File path: game/README.md
##########
@@ -6,7 +6,263 @@
 - The two services communicate with each other RPC (both registered **provider** and **consumer**)
 - The **gate** additionally starts the http service (port **8000**), which is used to manually trigger the **gate** RPC to call **game**
 
-> After each **gate** RPC call (**Message**) **game**, **game** will synchronize the RPC call (Send) **gate** pushes the same message
-> This logic is annotated by default, and the location is `go-server-game/pkg/provider.go` (line 25 ~ 30)
+> Each time **gate** RPC calls (**message**) **game**, **game** will synchronously call RPC (send) **gate** to push the same message. There are two services in samples, one is basketball service, the other is jumpservice. The jumpservice part has been commented out, and the content is basically the same as basketball.
+
+### outline
+
+Catalog description
+
+```shell
+├── go-server-game		# game module
+│   ├── cmd						# Main entrance
+│   ├── conf					# configuration file
+│   ├── docker				# docker-compose config file
+│   ├── pkg						# provider and consumer
+│   └── tests
+├── go-server-gate		# gate module
+│   ├── cmd						# Main entrance
+│   ├── conf					# configuration file
+│   ├── docker				# docker-compose config file
+│   ├── pkg						# provider and consumer
+│   └── tests
+└── pkg
+    ├── consumer			# public consumer
+    │   ├── game
+    │   └── gate
+    └── pojo
+```
+
+Process of initiating HTTP service
+
+<img src="http://cdn.cjpa.top/cdnimages/image-20210424095907886.png" alt="image-20210424095907886" style="zoom: 33%;" />
+
+
+
+From the perspective of consumer and provider, the process of initiating a call is like this
+
+<img src="http://cdn.cjpa.top/cdnimages/image-20210424100148028.png" alt="image-20210424100148028" style="zoom:33%;" />
+
+Game provides the basketball server and gate provides the HTTP server.
+
+### game module
+
+#### server side
+
+The server provides three services, message, online and offline. The code is as follows. The specific implementation can be in  game/go-server-game/pkg/provider.go see in.
+
+```go
+type BasketballService struct{}
+
+func (p *BasketballService) Online(...) (...) {
+    ...
+}
+
+func (p *BasketballService) Offline(...) (...) {
+    ...
+}
+
+func (p *BasketballService) Message(...) (...) {
+    ...
+}
+
+func (p *BasketballService) Reference() string {
+    return "gameProvider.basketballService"
+}
+```
+
+##### configuration file
+
+Register the service in the configuration file, where gameProvider.basketballService Same as declared in the reference method.
+
+```yml
+services:
+  "gameProvider.basketballService":
+    registry: "demoZk"
+    protocol: "dubbo"
+    interface: "org.apache.dubbo.game.BasketballService"
+    loadbalance: "random"
+    warmup: "100"
+    cluster: "failover"
+    methods:
+      - name: "Online"
+        retries: 0
+      - name: "Offline"
+        retries: 0
+      - name: "Message"
+        retries: 
+```
+
+#### consumer side
+
+The consumer of basketball is mainly used to be called by gate, so the main code is put in game/pkg/consumer/gate/basketball.go,  The consumer code is as follows.
+
+```go
+type BasketballService struct {
+    Send func(ctx context.Context, uid string, data string) (*pojo.Result, error)
+}
+
+func (p *BasketballService) Reference() string {
+    return "gateConsumer.basketballService"
+}
+```
+
+In basketball, you only need to instantiate a consumer variable.
+
+```go
+var gateBasketball = new(gate.BasketballService)
+```
+
+Then register to Dubbo go in main.
+
+```go
+config.SetConsumerService(gateBasketball)
+```
+
+##### configuration file
+
+```yml
+references:
+  "gateConsumer.basketballService":
+    registry: "demoZk"
+    protocol : "dubbo"
+    interface : "org.apache.dubbo.gate.BasketballService"
+    cluster: "failover"
+    methods:
+      - name: "Send"
+        retries: 0
+```
+
+Because the consumer of game needs to call the provider of gate, the string returned by the reference method is gateConsumer.basketballService  , in the configuration file gateConsumer.basketballService  And game/pkg/consumer/gate/basketball.go  The value of intreface should be consistent with that of the provider of gate.
+
+### gate module
+
+#### server side
+
+```go
+type BasketballService struct{}
+
+func (p *BasketballService) Send(ctx context.Context, uid, data string) (*pojo.Result, error) {
+...
+}
+
+func (p *BasketballService) Reference() string {
+    return "gateProvider.basketballService"
+}
+```
+
+Register with Dubbo
+
+```go
+config.SetProviderService(new(BasketballService))
+```
+
+##### configuration file
+
+gateProvider.basketballService  The interface here must be the same as that in game client.yml  The settings in the file should be consistent, otherwise game cannot send data to gate.
+
+```yml
+# service config
+services:
+  "gateProvider.basketballService":
+    registry: "demoZk"
+    protocol : "dubbo"
+    interface : "org.apache.dubbo.gate.BasketballService"
+    loadbalance: "random"
+    warmup: "100"
+    cluster: "failover"
+    methods:
+      - name: "Send"
+        retries: 0
+```
+
+#### consumer size
+
+The consumer side of the gate is relatively special. Because the consumer of the gate needs to call the service in the game, in the game, the consumer directly instantiates the service of a game, and its method directly uses the instantiated object gamebasketball to call, thus realizing the function of a gateway.

Review comment:
       The consumer side of the gate is relatively special. Because the consumer of the gate needs to call the service in the game,  the consumer directly instantiates the service of a game, and its method directly uses the instantiated object gamebasketball to call, thus realizing the function of a gateway.




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-samples] cjphaha commented on pull request #97: add readme of game

Posted by GitBox <gi...@apache.org>.
cjphaha commented on pull request #97:
URL: https://github.com/apache/dubbo-go-samples/pull/97#issuecomment-826357799


   可以等前端做好了之后再merge


-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-samples] AlexStocks commented on a change in pull request #97: add readme of game

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on a change in pull request #97:
URL: https://github.com/apache/dubbo-go-samples/pull/97#discussion_r619729749



##########
File path: game/README_zh.md
##########
@@ -4,10 +4,270 @@
 
 - 示例包含 **gate** (网关服务) 和 **game** (逻辑服务) 两个服务
 - 两个服务会互相 RPC 通讯 (都同时注册 **provider** 和 **consumer**)
-- **gate** 额外启动了 http 服务 (端口 **8000**), 用于手工触发 **gate** RPC调用 **game**
+- **gate** 额外启动了 http 服务 (端口 **8000**), 用于手工触发  **gate** RPC 调用 **game**
+
+> 每次 **gate** RPC调用(**Message**) **game** 后, **game** 会同步RPC调用(Send) **gate** 推送相同消息,samples中有两个服务,一个是 basketballService,一个是 jumpService,其中 jumpService 部分已经注释掉,内容和basketball 基本一致。
+
+### 概要
+
+目录说明
+
+```bash
+├── go-server-game		# game模块
+│   ├── cmd						# 主入口
+│   ├── conf					# 配置文件
+│   ├── docker				# docker-compose文件
+│   ├── pkg						# provider和consumer
+│   └── tests
+├── go-server-gate		# gate模块
+│   ├── cmd						# 主入口
+│   ├── conf					# 配置文件
+│   ├── docker				# docker-compose文件
+│   ├── pkg						# provider和consumer
+│   └── tests
+└── pkg
+    ├── consumer			# 公共consumer
+    │   ├── game
+    │   └── gate
+    └── pojo
+```
+
+发起http服务的流程
+
+<img src="http://cdn.cjpa.top/cdnimages/image-20210423212453935.png" alt="image-20210423212453935" style="zoom:50%;" />
+
+
+
+从consumer和provider角度来看,发起一次调用的流程是这样的
+
+<img src="http://cdn.cjpa.top/cdnimages/image-20210424094134541.png" alt="image-20210424094134541" style="zoom: 33%;" />
+
+game提供了basketball服务端,gate提供了http服务端。
+
+### game模块
+
+#### server端
+
+server 端提供三个服务,message、online 及 offline,代码如下,具体的实现可以在 game/go-server-game/pkg/provider.go 中看到
+
+```go
+type BasketballService struct{}
+
+func (p *BasketballService) Online(...) (...) {
+    ...
+}
+
+func (p *BasketballService) Offline(...) (...) {
+    ...
+}
+
+func (p *BasketballService) Message(...) (...) {
+    ...
+}
+
+func (p *BasketballService) Reference() string {
+    return "gameProvider.basketballService"
+}
+```
+
+##### 配置文件
+
+ 在配置文件中注册 service,其中 gameProvider.basketballService 和 Reference 方法中声明的一致。
+
+```yml
+services:
+  "gameProvider.basketballService":
+    registry: "demoZk"
+    protocol: "dubbo"
+    interface: "org.apache.dubbo.game.BasketballService"
+    loadbalance: "random"
+    warmup: "100"
+    cluster: "failover"
+    methods:
+      - name: "Online"
+        retries: 0
+      - name: "Offline"
+        retries: 0
+      - name: "Message"
+        retries: 
+```
+
+#### consumer端
+
+basketball 部分的 consumer 主要用来被 gate 调用,因此主要代码放在了 game/pkg/consumer/gate/basketball.go 中,这部分作为公共部分,consumer 代码如下
+
+```go
+type BasketballService struct {
+    Send func(ctx context.Context, uid string, data string) (*pojo.Result, error)
+}
+
+func (p *BasketballService) Reference() string {
+    return "gateConsumer.basketballService"
+}
+```
+
+在basketball中,只需要实例化一个consumer变量即可
+
+```go
+var gateBasketball = new(gate.BasketballService)
+```
+
+然后在main中注册到dubbo-go
+
+```go
+config.SetConsumerService(gateBasketball)
+```
+
+##### 配置文件
+
+```yml
+references:
+  "gateConsumer.basketballService":
+    registry: "demoZk"
+    protocol : "dubbo"
+    interface : "org.apache.dubbo.gate.BasketballService"
+    cluster: "failover"
+    methods:
+      - name: "Send"
+        retries: 0
+```
+
+由于 game 的 consumer 需要调用 gate 的provider,因此 Reference 方法返回的字符串为 gateConsumer.basketballService ,在配置文件中中 gateConsumer.basketballService 和 game/pkg/consumer/gate/basketball.go 中Reference 方法声明的一致,intreface 的值也要和 gate 的 provider 设置的一致。

Review comment:
       '文件中中' = '文件中'。另外,在源码文明名称前后加上单引号。




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-samples] zouyx merged pull request #97: add readme of game

Posted by GitBox <gi...@apache.org>.
zouyx merged pull request #97:
URL: https://github.com/apache/dubbo-go-samples/pull/97


   


-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-samples] AlexStocks commented on a change in pull request #97: add readme of game

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on a change in pull request #97:
URL: https://github.com/apache/dubbo-go-samples/pull/97#discussion_r619729443



##########
File path: game/README.md
##########
@@ -6,7 +6,263 @@
 - The two services communicate with each other RPC (both registered **provider** and **consumer**)
 - The **gate** additionally starts the http service (port **8000**), which is used to manually trigger the **gate** RPC to call **game**
 
-> After each **gate** RPC call (**Message**) **game**, **game** will synchronize the RPC call (Send) **gate** pushes the same message
-> This logic is annotated by default, and the location is `go-server-game/pkg/provider.go` (line 25 ~ 30)
+> Each time **gate** RPC calls (**message**) **game**, **game** will synchronously call RPC (send) **gate** to push the same message. There are two services in samples, one is basketball service, the other is jumpservice. The jumpservice part has been commented out, and the content is basically the same as basketball.
+
+### outline
+
+Catalog description
+
+```shell
+├── go-server-game		# game module

Review comment:
       把这块右边的注释对齐




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-samples] AlexStocks commented on a change in pull request #97: add readme of game

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on a change in pull request #97:
URL: https://github.com/apache/dubbo-go-samples/pull/97#discussion_r619729414



##########
File path: game/README.md
##########
@@ -6,7 +6,263 @@
 - The two services communicate with each other RPC (both registered **provider** and **consumer**)
 - The **gate** additionally starts the http service (port **8000**), which is used to manually trigger the **gate** RPC to call **game**
 
-> After each **gate** RPC call (**Message**) **game**, **game** will synchronize the RPC call (Send) **gate** pushes the same message
-> This logic is annotated by default, and the location is `go-server-game/pkg/provider.go` (line 25 ~ 30)
+> Each time **gate** RPC calls (**message**) **game**, **game** will synchronously call RPC (send) **gate** to push the same message. There are two services in samples, one is basketball service, the other is jumpservice. The jumpservice part has been commented out, and the content is basically the same as basketball.

Review comment:
       ”has been commented out“  => has been ramarked. 另外,如果已经注释掉,何不直接删掉算了?

##########
File path: game/README.md
##########
@@ -6,7 +6,263 @@
 - The two services communicate with each other RPC (both registered **provider** and **consumer**)
 - The **gate** additionally starts the http service (port **8000**), which is used to manually trigger the **gate** RPC to call **game**
 
-> After each **gate** RPC call (**Message**) **game**, **game** will synchronize the RPC call (Send) **gate** pushes the same message
-> This logic is annotated by default, and the location is `go-server-game/pkg/provider.go` (line 25 ~ 30)
+> Each time **gate** RPC calls (**message**) **game**, **game** will synchronously call RPC (send) **gate** to push the same message. There are two services in samples, one is basketball service, the other is jumpservice. The jumpservice part has been commented out, and the content is basically the same as basketball.
+
+### outline
+
+Catalog description
+
+```shell
+├── go-server-game		# game module

Review comment:
       把这块右边的注释对齐

##########
File path: game/README.md
##########
@@ -6,7 +6,263 @@
 - The two services communicate with each other RPC (both registered **provider** and **consumer**)
 - The **gate** additionally starts the http service (port **8000**), which is used to manually trigger the **gate** RPC to call **game**
 
-> After each **gate** RPC call (**Message**) **game**, **game** will synchronize the RPC call (Send) **gate** pushes the same message
-> This logic is annotated by default, and the location is `go-server-game/pkg/provider.go` (line 25 ~ 30)
+> Each time **gate** RPC calls (**message**) **game**, **game** will synchronously call RPC (send) **gate** to push the same message. There are two services in samples, one is basketball service, the other is jumpservice. The jumpservice part has been commented out, and the content is basically the same as basketball.
+
+### outline
+
+Catalog description
+
+```shell
+├── go-server-game		# game module
+│   ├── cmd						# Main entrance
+│   ├── conf					# configuration file
+│   ├── docker				# docker-compose config file
+│   ├── pkg						# provider and consumer
+│   └── tests
+├── go-server-gate		# gate module
+│   ├── cmd						# Main entrance
+│   ├── conf					# configuration file
+│   ├── docker				# docker-compose config file
+│   ├── pkg						# provider and consumer
+│   └── tests
+└── pkg
+    ├── consumer			# public consumer
+    │   ├── game
+    │   └── gate
+    └── pojo
+```
+
+Process of initiating HTTP service
+
+<img src="http://cdn.cjpa.top/cdnimages/image-20210424095907886.png" alt="image-20210424095907886" style="zoom: 33%;" />
+
+
+
+From the perspective of consumer and provider, the process of initiating a call is like this

Review comment:
       'like this' => 'as follows'.

##########
File path: game/README.md
##########
@@ -6,7 +6,263 @@
 - The two services communicate with each other RPC (both registered **provider** and **consumer**)
 - The **gate** additionally starts the http service (port **8000**), which is used to manually trigger the **gate** RPC to call **game**
 
-> After each **gate** RPC call (**Message**) **game**, **game** will synchronize the RPC call (Send) **gate** pushes the same message
-> This logic is annotated by default, and the location is `go-server-game/pkg/provider.go` (line 25 ~ 30)
+> Each time **gate** RPC calls (**message**) **game**, **game** will synchronously call RPC (send) **gate** to push the same message. There are two services in samples, one is basketball service, the other is jumpservice. The jumpservice part has been commented out, and the content is basically the same as basketball.
+
+### outline
+
+Catalog description
+
+```shell
+├── go-server-game		# game module
+│   ├── cmd						# Main entrance
+│   ├── conf					# configuration file
+│   ├── docker				# docker-compose config file
+│   ├── pkg						# provider and consumer
+│   └── tests
+├── go-server-gate		# gate module
+│   ├── cmd						# Main entrance
+│   ├── conf					# configuration file
+│   ├── docker				# docker-compose config file
+│   ├── pkg						# provider and consumer
+│   └── tests
+└── pkg
+    ├── consumer			# public consumer
+    │   ├── game
+    │   └── gate
+    └── pojo
+```
+
+Process of initiating HTTP service
+
+<img src="http://cdn.cjpa.top/cdnimages/image-20210424095907886.png" alt="image-20210424095907886" style="zoom: 33%;" />
+
+
+
+From the perspective of consumer and provider, the process of initiating a call is like this
+
+<img src="http://cdn.cjpa.top/cdnimages/image-20210424100148028.png" alt="image-20210424100148028" style="zoom:33%;" />
+
+Game provides the basketball server and gate provides the HTTP server.
+
+### game module
+
+#### server side
+
+The server provides three services, message, online and offline. The code is as follows. The specific implementation can be in  game/go-server-game/pkg/provider.go see in.
+
+```go
+type BasketballService struct{}
+
+func (p *BasketballService) Online(...) (...) {
+    ...
+}
+
+func (p *BasketballService) Offline(...) (...) {
+    ...
+}
+
+func (p *BasketballService) Message(...) (...) {
+    ...
+}
+
+func (p *BasketballService) Reference() string {
+    return "gameProvider.basketballService"
+}
+```
+
+##### configuration file
+
+Register the service in the configuration file, where gameProvider.basketballService Same as declared in the reference method.
+
+```yml
+services:
+  "gameProvider.basketballService":
+    registry: "demoZk"
+    protocol: "dubbo"
+    interface: "org.apache.dubbo.game.BasketballService"
+    loadbalance: "random"
+    warmup: "100"
+    cluster: "failover"
+    methods:
+      - name: "Online"
+        retries: 0
+      - name: "Offline"
+        retries: 0
+      - name: "Message"
+        retries: 
+```
+
+#### consumer side
+
+The consumer of basketball is mainly used to be called by gate, so the main code is put in game/pkg/consumer/gate/basketball.go,  The consumer code is as follows.
+
+```go
+type BasketballService struct {
+    Send func(ctx context.Context, uid string, data string) (*pojo.Result, error)
+}
+
+func (p *BasketballService) Reference() string {
+    return "gateConsumer.basketballService"
+}
+```
+
+In basketball, you only need to instantiate a consumer variable.
+
+```go
+var gateBasketball = new(gate.BasketballService)
+```
+
+Then register to Dubbo go in main.
+
+```go
+config.SetConsumerService(gateBasketball)
+```
+
+##### configuration file
+
+```yml
+references:
+  "gateConsumer.basketballService":
+    registry: "demoZk"
+    protocol : "dubbo"
+    interface : "org.apache.dubbo.gate.BasketballService"
+    cluster: "failover"
+    methods:
+      - name: "Send"
+        retries: 0
+```
+
+Because the consumer of game needs to call the provider of gate, the string returned by the reference method is gateConsumer.basketballService  , in the configuration file gateConsumer.basketballService  And game/pkg/consumer/gate/basketball.go  The value of intreface should be consistent with that of the provider of gate.

Review comment:
       Because the consumer of game needs to call the provider of gate, the string returned by the reference method is gateConsumer.basketballService , in the configuration file gateConsumer.basketballService  And 'game/pkg/consumer/gate/basketball.go'. The value of interface should be consistent with that of the provider of gate.

##########
File path: game/README.md
##########
@@ -6,7 +6,263 @@
 - The two services communicate with each other RPC (both registered **provider** and **consumer**)
 - The **gate** additionally starts the http service (port **8000**), which is used to manually trigger the **gate** RPC to call **game**
 
-> After each **gate** RPC call (**Message**) **game**, **game** will synchronize the RPC call (Send) **gate** pushes the same message
-> This logic is annotated by default, and the location is `go-server-game/pkg/provider.go` (line 25 ~ 30)
+> Each time **gate** RPC calls (**message**) **game**, **game** will synchronously call RPC (send) **gate** to push the same message. There are two services in samples, one is basketball service, the other is jumpservice. The jumpservice part has been commented out, and the content is basically the same as basketball.
+
+### outline
+
+Catalog description
+
+```shell
+├── go-server-game		# game module
+│   ├── cmd						# Main entrance
+│   ├── conf					# configuration file
+│   ├── docker				# docker-compose config file
+│   ├── pkg						# provider and consumer
+│   └── tests
+├── go-server-gate		# gate module
+│   ├── cmd						# Main entrance
+│   ├── conf					# configuration file
+│   ├── docker				# docker-compose config file
+│   ├── pkg						# provider and consumer
+│   └── tests
+└── pkg
+    ├── consumer			# public consumer
+    │   ├── game
+    │   └── gate
+    └── pojo
+```
+
+Process of initiating HTTP service
+
+<img src="http://cdn.cjpa.top/cdnimages/image-20210424095907886.png" alt="image-20210424095907886" style="zoom: 33%;" />
+
+
+
+From the perspective of consumer and provider, the process of initiating a call is like this
+
+<img src="http://cdn.cjpa.top/cdnimages/image-20210424100148028.png" alt="image-20210424100148028" style="zoom:33%;" />
+
+Game provides the basketball server and gate provides the HTTP server.
+
+### game module
+
+#### server side
+
+The server provides three services, message, online and offline. The code is as follows. The specific implementation can be in  game/go-server-game/pkg/provider.go see in.
+
+```go
+type BasketballService struct{}
+
+func (p *BasketballService) Online(...) (...) {
+    ...
+}
+
+func (p *BasketballService) Offline(...) (...) {
+    ...
+}
+
+func (p *BasketballService) Message(...) (...) {
+    ...
+}
+
+func (p *BasketballService) Reference() string {
+    return "gameProvider.basketballService"
+}
+```
+
+##### configuration file
+
+Register the service in the configuration file, where gameProvider.basketballService Same as declared in the reference method.
+
+```yml
+services:
+  "gameProvider.basketballService":
+    registry: "demoZk"
+    protocol: "dubbo"
+    interface: "org.apache.dubbo.game.BasketballService"
+    loadbalance: "random"
+    warmup: "100"
+    cluster: "failover"
+    methods:
+      - name: "Online"
+        retries: 0
+      - name: "Offline"
+        retries: 0
+      - name: "Message"
+        retries: 
+```
+
+#### consumer side
+
+The consumer of basketball is mainly used to be called by gate, so the main code is put in game/pkg/consumer/gate/basketball.go,  The consumer code is as follows.
+
+```go
+type BasketballService struct {
+    Send func(ctx context.Context, uid string, data string) (*pojo.Result, error)
+}
+
+func (p *BasketballService) Reference() string {
+    return "gateConsumer.basketballService"
+}
+```
+
+In basketball, you only need to instantiate a consumer variable.
+
+```go
+var gateBasketball = new(gate.BasketballService)
+```
+
+Then register to Dubbo go in main.
+
+```go
+config.SetConsumerService(gateBasketball)
+```
+
+##### configuration file
+
+```yml
+references:
+  "gateConsumer.basketballService":
+    registry: "demoZk"
+    protocol : "dubbo"
+    interface : "org.apache.dubbo.gate.BasketballService"
+    cluster: "failover"
+    methods:
+      - name: "Send"
+        retries: 0
+```
+
+Because the consumer of game needs to call the provider of gate, the string returned by the reference method is gateConsumer.basketballService  , in the configuration file gateConsumer.basketballService  And game/pkg/consumer/gate/basketball.go  The value of intreface should be consistent with that of the provider of gate.
+
+### gate module
+
+#### server side
+
+```go
+type BasketballService struct{}
+
+func (p *BasketballService) Send(ctx context.Context, uid, data string) (*pojo.Result, error) {
+...
+}
+
+func (p *BasketballService) Reference() string {
+    return "gateProvider.basketballService"
+}
+```
+
+Register with Dubbo
+
+```go
+config.SetProviderService(new(BasketballService))
+```
+
+##### configuration file
+
+gateProvider.basketballService  The interface here must be the same as that in game client.yml  The settings in the file should be consistent, otherwise game cannot send data to gate.
+
+```yml
+# service config
+services:
+  "gateProvider.basketballService":
+    registry: "demoZk"
+    protocol : "dubbo"
+    interface : "org.apache.dubbo.gate.BasketballService"
+    loadbalance: "random"
+    warmup: "100"
+    cluster: "failover"
+    methods:
+      - name: "Send"
+        retries: 0
+```
+
+#### consumer size
+
+The consumer side of the gate is relatively special. Because the consumer of the gate needs to call the service in the game, in the game, the consumer directly instantiates the service of a game, and its method directly uses the instantiated object gamebasketball to call, thus realizing the function of a gateway.

Review comment:
       The consumer side of the gate is relatively special. Because the consumer of the gate needs to call the service in the game,  the consumer directly instantiates the service of a game, and its method directly uses the instantiated object gamebasketball to call, thus realizing the function of a gateway.

##########
File path: game/README_zh.md
##########
@@ -4,10 +4,270 @@
 
 - 示例包含 **gate** (网关服务) 和 **game** (逻辑服务) 两个服务
 - 两个服务会互相 RPC 通讯 (都同时注册 **provider** 和 **consumer**)
-- **gate** 额外启动了 http 服务 (端口 **8000**), 用于手工触发 **gate** RPC调用 **game**
+- **gate** 额外启动了 http 服务 (端口 **8000**), 用于手工触发  **gate** RPC 调用 **game**
+
+> 每次 **gate** RPC调用(**Message**) **game** 后, **game** 会同步RPC调用(Send) **gate** 推送相同消息,samples中有两个服务,一个是 basketballService,一个是 jumpService,其中 jumpService 部分已经注释掉,内容和basketball 基本一致。
+
+### 概要
+
+目录说明
+
+```bash

Review comment:
       同样,注释对齐

##########
File path: game/README_zh.md
##########
@@ -4,10 +4,270 @@
 
 - 示例包含 **gate** (网关服务) 和 **game** (逻辑服务) 两个服务
 - 两个服务会互相 RPC 通讯 (都同时注册 **provider** 和 **consumer**)
-- **gate** 额外启动了 http 服务 (端口 **8000**), 用于手工触发 **gate** RPC调用 **game**
+- **gate** 额外启动了 http 服务 (端口 **8000**), 用于手工触发  **gate** RPC 调用 **game**
+
+> 每次 **gate** RPC调用(**Message**) **game** 后, **game** 会同步RPC调用(Send) **gate** 推送相同消息,samples中有两个服务,一个是 basketballService,一个是 jumpService,其中 jumpService 部分已经注释掉,内容和basketball 基本一致。
+
+### 概要
+
+目录说明
+
+```bash
+├── go-server-game		# game模块
+│   ├── cmd						# 主入口
+│   ├── conf					# 配置文件
+│   ├── docker				# docker-compose文件
+│   ├── pkg						# provider和consumer
+│   └── tests
+├── go-server-gate		# gate模块
+│   ├── cmd						# 主入口
+│   ├── conf					# 配置文件
+│   ├── docker				# docker-compose文件
+│   ├── pkg						# provider和consumer
+│   └── tests
+└── pkg
+    ├── consumer			# 公共consumer
+    │   ├── game
+    │   └── gate
+    └── pojo
+```
+
+发起http服务的流程
+
+<img src="http://cdn.cjpa.top/cdnimages/image-20210423212453935.png" alt="image-20210423212453935" style="zoom:50%;" />
+
+
+
+从consumer和provider角度来看,发起一次调用的流程是这样的
+
+<img src="http://cdn.cjpa.top/cdnimages/image-20210424094134541.png" alt="image-20210424094134541" style="zoom: 33%;" />
+
+game提供了basketball服务端,gate提供了http服务端。
+
+### game模块
+
+#### server端
+
+server 端提供三个服务,message、online 及 offline,代码如下,具体的实现可以在 game/go-server-game/pkg/provider.go 中看到
+
+```go
+type BasketballService struct{}
+
+func (p *BasketballService) Online(...) (...) {
+    ...
+}
+
+func (p *BasketballService) Offline(...) (...) {
+    ...
+}
+
+func (p *BasketballService) Message(...) (...) {
+    ...
+}
+
+func (p *BasketballService) Reference() string {
+    return "gameProvider.basketballService"
+}
+```
+
+##### 配置文件
+
+ 在配置文件中注册 service,其中 gameProvider.basketballService 和 Reference 方法中声明的一致。
+
+```yml
+services:
+  "gameProvider.basketballService":
+    registry: "demoZk"
+    protocol: "dubbo"
+    interface: "org.apache.dubbo.game.BasketballService"
+    loadbalance: "random"
+    warmup: "100"
+    cluster: "failover"
+    methods:
+      - name: "Online"
+        retries: 0
+      - name: "Offline"
+        retries: 0
+      - name: "Message"
+        retries: 
+```
+
+#### consumer端
+
+basketball 部分的 consumer 主要用来被 gate 调用,因此主要代码放在了 game/pkg/consumer/gate/basketball.go 中,这部分作为公共部分,consumer 代码如下
+
+```go
+type BasketballService struct {
+    Send func(ctx context.Context, uid string, data string) (*pojo.Result, error)
+}
+
+func (p *BasketballService) Reference() string {
+    return "gateConsumer.basketballService"
+}
+```
+
+在basketball中,只需要实例化一个consumer变量即可
+
+```go
+var gateBasketball = new(gate.BasketballService)
+```
+
+然后在main中注册到dubbo-go
+
+```go
+config.SetConsumerService(gateBasketball)
+```
+
+##### 配置文件
+
+```yml
+references:
+  "gateConsumer.basketballService":
+    registry: "demoZk"
+    protocol : "dubbo"
+    interface : "org.apache.dubbo.gate.BasketballService"
+    cluster: "failover"
+    methods:
+      - name: "Send"
+        retries: 0
+```
+
+由于 game 的 consumer 需要调用 gate 的provider,因此 Reference 方法返回的字符串为 gateConsumer.basketballService ,在配置文件中中 gateConsumer.basketballService 和 game/pkg/consumer/gate/basketball.go 中Reference 方法声明的一致,intreface 的值也要和 gate 的 provider 设置的一致。

Review comment:
       '文件中中' = '文件中'。另外,在源码文明名称前后加上单引号。




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-samples] AlexStocks commented on a change in pull request #97: add readme of game

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on a change in pull request #97:
URL: https://github.com/apache/dubbo-go-samples/pull/97#discussion_r619729514



##########
File path: game/README.md
##########
@@ -6,7 +6,263 @@
 - The two services communicate with each other RPC (both registered **provider** and **consumer**)
 - The **gate** additionally starts the http service (port **8000**), which is used to manually trigger the **gate** RPC to call **game**
 
-> After each **gate** RPC call (**Message**) **game**, **game** will synchronize the RPC call (Send) **gate** pushes the same message
-> This logic is annotated by default, and the location is `go-server-game/pkg/provider.go` (line 25 ~ 30)
+> Each time **gate** RPC calls (**message**) **game**, **game** will synchronously call RPC (send) **gate** to push the same message. There are two services in samples, one is basketball service, the other is jumpservice. The jumpservice part has been commented out, and the content is basically the same as basketball.
+
+### outline
+
+Catalog description
+
+```shell
+├── go-server-game		# game module
+│   ├── cmd						# Main entrance
+│   ├── conf					# configuration file
+│   ├── docker				# docker-compose config file
+│   ├── pkg						# provider and consumer
+│   └── tests
+├── go-server-gate		# gate module
+│   ├── cmd						# Main entrance
+│   ├── conf					# configuration file
+│   ├── docker				# docker-compose config file
+│   ├── pkg						# provider and consumer
+│   └── tests
+└── pkg
+    ├── consumer			# public consumer
+    │   ├── game
+    │   └── gate
+    └── pojo
+```
+
+Process of initiating HTTP service
+
+<img src="http://cdn.cjpa.top/cdnimages/image-20210424095907886.png" alt="image-20210424095907886" style="zoom: 33%;" />
+
+
+
+From the perspective of consumer and provider, the process of initiating a call is like this

Review comment:
       'like this' => 'as follows'.




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-samples] AlexStocks commented on a change in pull request #97: add readme of game

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on a change in pull request #97:
URL: https://github.com/apache/dubbo-go-samples/pull/97#discussion_r619729591



##########
File path: game/README.md
##########
@@ -6,7 +6,263 @@
 - The two services communicate with each other RPC (both registered **provider** and **consumer**)
 - The **gate** additionally starts the http service (port **8000**), which is used to manually trigger the **gate** RPC to call **game**
 
-> After each **gate** RPC call (**Message**) **game**, **game** will synchronize the RPC call (Send) **gate** pushes the same message
-> This logic is annotated by default, and the location is `go-server-game/pkg/provider.go` (line 25 ~ 30)
+> Each time **gate** RPC calls (**message**) **game**, **game** will synchronously call RPC (send) **gate** to push the same message. There are two services in samples, one is basketball service, the other is jumpservice. The jumpservice part has been commented out, and the content is basically the same as basketball.
+
+### outline
+
+Catalog description
+
+```shell
+├── go-server-game		# game module
+│   ├── cmd						# Main entrance
+│   ├── conf					# configuration file
+│   ├── docker				# docker-compose config file
+│   ├── pkg						# provider and consumer
+│   └── tests
+├── go-server-gate		# gate module
+│   ├── cmd						# Main entrance
+│   ├── conf					# configuration file
+│   ├── docker				# docker-compose config file
+│   ├── pkg						# provider and consumer
+│   └── tests
+└── pkg
+    ├── consumer			# public consumer
+    │   ├── game
+    │   └── gate
+    └── pojo
+```
+
+Process of initiating HTTP service
+
+<img src="http://cdn.cjpa.top/cdnimages/image-20210424095907886.png" alt="image-20210424095907886" style="zoom: 33%;" />
+
+
+
+From the perspective of consumer and provider, the process of initiating a call is like this
+
+<img src="http://cdn.cjpa.top/cdnimages/image-20210424100148028.png" alt="image-20210424100148028" style="zoom:33%;" />
+
+Game provides the basketball server and gate provides the HTTP server.
+
+### game module
+
+#### server side
+
+The server provides three services, message, online and offline. The code is as follows. The specific implementation can be in  game/go-server-game/pkg/provider.go see in.
+
+```go
+type BasketballService struct{}
+
+func (p *BasketballService) Online(...) (...) {
+    ...
+}
+
+func (p *BasketballService) Offline(...) (...) {
+    ...
+}
+
+func (p *BasketballService) Message(...) (...) {
+    ...
+}
+
+func (p *BasketballService) Reference() string {
+    return "gameProvider.basketballService"
+}
+```
+
+##### configuration file
+
+Register the service in the configuration file, where gameProvider.basketballService Same as declared in the reference method.
+
+```yml
+services:
+  "gameProvider.basketballService":
+    registry: "demoZk"
+    protocol: "dubbo"
+    interface: "org.apache.dubbo.game.BasketballService"
+    loadbalance: "random"
+    warmup: "100"
+    cluster: "failover"
+    methods:
+      - name: "Online"
+        retries: 0
+      - name: "Offline"
+        retries: 0
+      - name: "Message"
+        retries: 
+```
+
+#### consumer side
+
+The consumer of basketball is mainly used to be called by gate, so the main code is put in game/pkg/consumer/gate/basketball.go,  The consumer code is as follows.
+
+```go
+type BasketballService struct {
+    Send func(ctx context.Context, uid string, data string) (*pojo.Result, error)
+}
+
+func (p *BasketballService) Reference() string {
+    return "gateConsumer.basketballService"
+}
+```
+
+In basketball, you only need to instantiate a consumer variable.
+
+```go
+var gateBasketball = new(gate.BasketballService)
+```
+
+Then register to Dubbo go in main.
+
+```go
+config.SetConsumerService(gateBasketball)
+```
+
+##### configuration file
+
+```yml
+references:
+  "gateConsumer.basketballService":
+    registry: "demoZk"
+    protocol : "dubbo"
+    interface : "org.apache.dubbo.gate.BasketballService"
+    cluster: "failover"
+    methods:
+      - name: "Send"
+        retries: 0
+```
+
+Because the consumer of game needs to call the provider of gate, the string returned by the reference method is gateConsumer.basketballService  , in the configuration file gateConsumer.basketballService  And game/pkg/consumer/gate/basketball.go  The value of intreface should be consistent with that of the provider of gate.

Review comment:
       Because the consumer of game needs to call the provider of gate, the string returned by the reference method is gateConsumer.basketballService , in the configuration file gateConsumer.basketballService  And 'game/pkg/consumer/gate/basketball.go'. The value of interface should be consistent with that of the provider of gate.




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-samples] cjphaha commented on a change in pull request #97: add readme of game

Posted by GitBox <gi...@apache.org>.
cjphaha commented on a change in pull request #97:
URL: https://github.com/apache/dubbo-go-samples/pull/97#discussion_r619793313



##########
File path: game/README_zh.md
##########
@@ -4,10 +4,270 @@
 
 - 示例包含 **gate** (网关服务) 和 **game** (逻辑服务) 两个服务
 - 两个服务会互相 RPC 通讯 (都同时注册 **provider** 和 **consumer**)
-- **gate** 额外启动了 http 服务 (端口 **8000**), 用于手工触发 **gate** RPC调用 **game**
+- **gate** 额外启动了 http 服务 (端口 **8000**), 用于手工触发  **gate** RPC 调用 **game**
+
+> 每次 **gate** RPC调用(**Message**) **game** 后, **game** 会同步RPC调用(Send) **gate** 推送相同消息,samples中有两个服务,一个是 basketballService,一个是 jumpService,其中 jumpService 部分已经注释掉,内容和basketball 基本一致。
+
+### 概要
+
+目录说明
+
+```bash
+├── go-server-game		# game模块
+│   ├── cmd						# 主入口
+│   ├── conf					# 配置文件
+│   ├── docker				# docker-compose文件
+│   ├── pkg						# provider和consumer
+│   └── tests
+├── go-server-gate		# gate模块
+│   ├── cmd						# 主入口
+│   ├── conf					# 配置文件
+│   ├── docker				# docker-compose文件
+│   ├── pkg						# provider和consumer
+│   └── tests
+└── pkg
+    ├── consumer			# 公共consumer
+    │   ├── game
+    │   └── gate
+    └── pojo
+```
+
+发起http服务的流程
+
+<img src="http://cdn.cjpa.top/cdnimages/image-20210423212453935.png" alt="image-20210423212453935" style="zoom:50%;" />
+
+
+
+从consumer和provider角度来看,发起一次调用的流程是这样的
+
+<img src="http://cdn.cjpa.top/cdnimages/image-20210424094134541.png" alt="image-20210424094134541" style="zoom: 33%;" />
+
+game提供了basketball服务端,gate提供了http服务端。
+
+### game模块
+
+#### server端
+
+server 端提供三个服务,message、online 及 offline,代码如下,具体的实现可以在 game/go-server-game/pkg/provider.go 中看到
+
+```go
+type BasketballService struct{}
+
+func (p *BasketballService) Online(...) (...) {
+    ...
+}
+
+func (p *BasketballService) Offline(...) (...) {
+    ...
+}
+
+func (p *BasketballService) Message(...) (...) {
+    ...
+}
+
+func (p *BasketballService) Reference() string {
+    return "gameProvider.basketballService"
+}
+```
+
+##### 配置文件
+
+ 在配置文件中注册 service,其中 gameProvider.basketballService 和 Reference 方法中声明的一致。
+
+```yml
+services:
+  "gameProvider.basketballService":
+    registry: "demoZk"
+    protocol: "dubbo"
+    interface: "org.apache.dubbo.game.BasketballService"
+    loadbalance: "random"
+    warmup: "100"
+    cluster: "failover"
+    methods:
+      - name: "Online"
+        retries: 0
+      - name: "Offline"
+        retries: 0
+      - name: "Message"
+        retries: 
+```
+
+#### consumer端
+
+basketball 部分的 consumer 主要用来被 gate 调用,因此主要代码放在了 game/pkg/consumer/gate/basketball.go 中,这部分作为公共部分,consumer 代码如下
+
+```go
+type BasketballService struct {
+    Send func(ctx context.Context, uid string, data string) (*pojo.Result, error)
+}
+
+func (p *BasketballService) Reference() string {
+    return "gateConsumer.basketballService"
+}
+```
+
+在basketball中,只需要实例化一个consumer变量即可
+
+```go
+var gateBasketball = new(gate.BasketballService)
+```
+
+然后在main中注册到dubbo-go
+
+```go
+config.SetConsumerService(gateBasketball)
+```
+
+##### 配置文件
+
+```yml
+references:
+  "gateConsumer.basketballService":
+    registry: "demoZk"
+    protocol : "dubbo"
+    interface : "org.apache.dubbo.gate.BasketballService"
+    cluster: "failover"
+    methods:
+      - name: "Send"
+        retries: 0
+```
+
+由于 game 的 consumer 需要调用 gate 的provider,因此 Reference 方法返回的字符串为 gateConsumer.basketballService ,在配置文件中中 gateConsumer.basketballService 和 game/pkg/consumer/gate/basketball.go 中Reference 方法声明的一致,intreface 的值也要和 gate 的 provider 设置的一致。

Review comment:
       感谢感谢,我晚上改一下😬




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-samples] cjphaha commented on pull request #97: add readme of game

Posted by GitBox <gi...@apache.org>.
cjphaha commented on pull request #97:
URL: https://github.com/apache/dubbo-go-samples/pull/97#issuecomment-826357799


   可以等前端做好了之后再merge


-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-samples] AlexStocks commented on a change in pull request #97: add readme of game

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on a change in pull request #97:
URL: https://github.com/apache/dubbo-go-samples/pull/97#discussion_r619729414



##########
File path: game/README.md
##########
@@ -6,7 +6,263 @@
 - The two services communicate with each other RPC (both registered **provider** and **consumer**)
 - The **gate** additionally starts the http service (port **8000**), which is used to manually trigger the **gate** RPC to call **game**
 
-> After each **gate** RPC call (**Message**) **game**, **game** will synchronize the RPC call (Send) **gate** pushes the same message
-> This logic is annotated by default, and the location is `go-server-game/pkg/provider.go` (line 25 ~ 30)
+> Each time **gate** RPC calls (**message**) **game**, **game** will synchronously call RPC (send) **gate** to push the same message. There are two services in samples, one is basketball service, the other is jumpservice. The jumpservice part has been commented out, and the content is basically the same as basketball.

Review comment:
       ”has been commented out“  => has been ramarked. 另外,如果已经注释掉,何不直接删掉算了?




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-samples] AlexStocks commented on a change in pull request #97: add readme of game

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on a change in pull request #97:
URL: https://github.com/apache/dubbo-go-samples/pull/97#discussion_r619729674



##########
File path: game/README_zh.md
##########
@@ -4,10 +4,270 @@
 
 - 示例包含 **gate** (网关服务) 和 **game** (逻辑服务) 两个服务
 - 两个服务会互相 RPC 通讯 (都同时注册 **provider** 和 **consumer**)
-- **gate** 额外启动了 http 服务 (端口 **8000**), 用于手工触发 **gate** RPC调用 **game**
+- **gate** 额外启动了 http 服务 (端口 **8000**), 用于手工触发  **gate** RPC 调用 **game**
+
+> 每次 **gate** RPC调用(**Message**) **game** 后, **game** 会同步RPC调用(Send) **gate** 推送相同消息,samples中有两个服务,一个是 basketballService,一个是 jumpService,其中 jumpService 部分已经注释掉,内容和basketball 基本一致。
+
+### 概要
+
+目录说明
+
+```bash

Review comment:
       同样,注释对齐




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-samples] cjphaha commented on a change in pull request #97: add readme of game

Posted by GitBox <gi...@apache.org>.
cjphaha commented on a change in pull request #97:
URL: https://github.com/apache/dubbo-go-samples/pull/97#discussion_r619793313



##########
File path: game/README_zh.md
##########
@@ -4,10 +4,270 @@
 
 - 示例包含 **gate** (网关服务) 和 **game** (逻辑服务) 两个服务
 - 两个服务会互相 RPC 通讯 (都同时注册 **provider** 和 **consumer**)
-- **gate** 额外启动了 http 服务 (端口 **8000**), 用于手工触发 **gate** RPC调用 **game**
+- **gate** 额外启动了 http 服务 (端口 **8000**), 用于手工触发  **gate** RPC 调用 **game**
+
+> 每次 **gate** RPC调用(**Message**) **game** 后, **game** 会同步RPC调用(Send) **gate** 推送相同消息,samples中有两个服务,一个是 basketballService,一个是 jumpService,其中 jumpService 部分已经注释掉,内容和basketball 基本一致。
+
+### 概要
+
+目录说明
+
+```bash
+├── go-server-game		# game模块
+│   ├── cmd						# 主入口
+│   ├── conf					# 配置文件
+│   ├── docker				# docker-compose文件
+│   ├── pkg						# provider和consumer
+│   └── tests
+├── go-server-gate		# gate模块
+│   ├── cmd						# 主入口
+│   ├── conf					# 配置文件
+│   ├── docker				# docker-compose文件
+│   ├── pkg						# provider和consumer
+│   └── tests
+└── pkg
+    ├── consumer			# 公共consumer
+    │   ├── game
+    │   └── gate
+    └── pojo
+```
+
+发起http服务的流程
+
+<img src="http://cdn.cjpa.top/cdnimages/image-20210423212453935.png" alt="image-20210423212453935" style="zoom:50%;" />
+
+
+
+从consumer和provider角度来看,发起一次调用的流程是这样的
+
+<img src="http://cdn.cjpa.top/cdnimages/image-20210424094134541.png" alt="image-20210424094134541" style="zoom: 33%;" />
+
+game提供了basketball服务端,gate提供了http服务端。
+
+### game模块
+
+#### server端
+
+server 端提供三个服务,message、online 及 offline,代码如下,具体的实现可以在 game/go-server-game/pkg/provider.go 中看到
+
+```go
+type BasketballService struct{}
+
+func (p *BasketballService) Online(...) (...) {
+    ...
+}
+
+func (p *BasketballService) Offline(...) (...) {
+    ...
+}
+
+func (p *BasketballService) Message(...) (...) {
+    ...
+}
+
+func (p *BasketballService) Reference() string {
+    return "gameProvider.basketballService"
+}
+```
+
+##### 配置文件
+
+ 在配置文件中注册 service,其中 gameProvider.basketballService 和 Reference 方法中声明的一致。
+
+```yml
+services:
+  "gameProvider.basketballService":
+    registry: "demoZk"
+    protocol: "dubbo"
+    interface: "org.apache.dubbo.game.BasketballService"
+    loadbalance: "random"
+    warmup: "100"
+    cluster: "failover"
+    methods:
+      - name: "Online"
+        retries: 0
+      - name: "Offline"
+        retries: 0
+      - name: "Message"
+        retries: 
+```
+
+#### consumer端
+
+basketball 部分的 consumer 主要用来被 gate 调用,因此主要代码放在了 game/pkg/consumer/gate/basketball.go 中,这部分作为公共部分,consumer 代码如下
+
+```go
+type BasketballService struct {
+    Send func(ctx context.Context, uid string, data string) (*pojo.Result, error)
+}
+
+func (p *BasketballService) Reference() string {
+    return "gateConsumer.basketballService"
+}
+```
+
+在basketball中,只需要实例化一个consumer变量即可
+
+```go
+var gateBasketball = new(gate.BasketballService)
+```
+
+然后在main中注册到dubbo-go
+
+```go
+config.SetConsumerService(gateBasketball)
+```
+
+##### 配置文件
+
+```yml
+references:
+  "gateConsumer.basketballService":
+    registry: "demoZk"
+    protocol : "dubbo"
+    interface : "org.apache.dubbo.gate.BasketballService"
+    cluster: "failover"
+    methods:
+      - name: "Send"
+        retries: 0
+```
+
+由于 game 的 consumer 需要调用 gate 的provider,因此 Reference 方法返回的字符串为 gateConsumer.basketballService ,在配置文件中中 gateConsumer.basketballService 和 game/pkg/consumer/gate/basketball.go 中Reference 方法声明的一致,intreface 的值也要和 gate 的 provider 设置的一致。

Review comment:
       感谢感谢,我晚上改一下😬




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org