-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
34 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
## GRPC使用 | ||
|
||
#### GRPC标准使用 | ||
>std中 | ||
#### gokit中使用grpc | ||
>kit中,输入,输出参数都使用了pb的生成的struct,没有自定义,如有需要,可以自定义,然后通过decode和encode,与业务逻辑接口进行对接。 | ||
##### transport | ||
>透明的,直接传递,不做任何解码编码。 | ||
##### pb的业务接口 | ||
>grpc中要实现pb中定义的接口,这个项目中,有2个地方实现了pb的接口。 | ||
1. 业务逻辑直接使用pb的接口。(可以自定义接口,与pb不耦合,但是要做encode和decode)。 | ||
2. grpc中注册的接口,通过gokit中的handler,endpoint中执行具体的业务逻辑,然后把返回的数据,转化成pb的格式。 | ||
|
||
#### 具体的业务逻辑 | ||
>biz中,业务逻辑接口直接使用了pb定义出来的接口,减少了自定义接口。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,6 @@ message LoginReq { | |
|
||
message LoginRes { | ||
int64 code = 1; | ||
string err = 2; | ||
string msg = 2; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,5 +29,5 @@ func main() { | |
} | ||
|
||
fmt.Println(res.Code) | ||
fmt.Println(res.Err) | ||
fmt.Println(res.Msg) | ||
} |