当前位置:网站首页>Golang RPC (7): how to debug grpc service
Golang RPC (7): how to debug grpc service
2022-06-09 12:32:00 【raoxiaoya】
gRPC The default is protobuf Encoded is not clear text , secondly , Be similar to RESTFUL API, We also need curl and postman Such a debugging tool .gRPC There are similar tools , The corresponding difference is grpcurl and grpcui.
grpcurl- Command line tools
similar curl, It can be directly used to send a request to call a remote grpc service , Please see the official address grpcurl
install
You can also use go get install
go get -u github.com/fullstorydev/grpcurl
go install github.com/fullstorydev/grpcurl/cmd/grpcurl
Use
Be careful grpcurl It's based on reflection , You need to add such a line of code before starting the service
s := grpc.NewServer()
reflection.Register(s)
1. Query service list
grpcurl -plaintext 127.0.0.1:50051 list
grpc.reflection.v1alpha.ServerReflection
helloworld.Greeter
2. Query the methods provided by the service
grpcurl -plaintext 127.0.0.1:50051 list helloworld.Greeter
helloworld.Greeter.SayHello
3. See a more detailed description
grpcurl -plaintext 127.0.0.1:50051 describe helloworld.Greeter
helloworld.Greeter is a service:
service Greeter {
rpc SayHello ( .helloworld.HelloRequest ) returns ( .helloworld.HelloReply );
}
4. Get type information
grpcurl -plaintext 127.0.0.1:50051 describe helloworld.HelloReply
Output
helloworld.HelloReply is a message:
message HelloReply {
string message = 1;
}
5. Call service method
grpcurl -plaintext -d '{"name":"rao"}' 127.0.0.1:50051 helloworld.Greeter/SayHello
Output
{
"message": "Hello rao"
}
grpcui- Interface tools
To put it simply , Namely gRPC Medium postman, Can take you to fly , Official address grpcui
install
go get -u github.com/fullstorydev/grpcui
go install github.com/fullstorydev/grpcui/cmd/grpcui
There is an error
/root/gowork/pkg/mod/github.com/fullstorydev/[email protected]/cmd/grpcui/grpcui.go:31:2: missing go.sum entry for module providing package github.com/pkg/browser (imported by github.com/fullstorydev/grpcui/cmd/grpcui); to add:
go get github.com/fullstorydev/grpcui/cmd/[email protected]
/root/gowork/pkg/mod/github.com/fullstorydev/[email protected]/cmd/grpcui/grpcui.go:32:2: missing go.sum entry for module providing package golang.org/x/crypto/ssh/terminal (imported by github.com/fullstorydev/grpcui/cmd/grpcui); to add:
go get github.com/fullstorydev/grpcui/cmd/[email protected]
perform
go get github.com/fullstorydev/grpcui/cmd/[email protected]
Use
function web Interface , Appoint grpc The address of
grpcui -plaintext localhost:50051
gRPC Web UI available at http://127.0.0.1:1728/
Tips Web UI The address for http://127.0.0.1:1728/
Access the following interface 
Input parameters , Initiate request


边栏推荐
- 10 | summary: summary of middle platform landing tool resources
- Nanny tutorial: how to become a contributor to Apache linkis documents
- 9.<tag-回溯和同层内去重的组合问题>lt.491. 递增子序列
- Excel | App_ Error in workbookactive cannot set the installed property of class addin
- 炒作剽窃、内鬼欺诈 OpenSea上常见的NFT骗局及安全建议
- 08 | middle stage landing step 3: middle stage planning and design
- UDP可靠性实践
- 13. Using WPF to develop USB detection tool
- 9. lt.491 Longest increasing subsequence
- 科研論文寫作
猜你喜欢

Fairness through awareness

Excel | App_ Error in workbookactive cannot set the installed property of class addin

03 | definition of China Taiwan: what are we talking about when we talk about China Taiwan?

BFS练手题目

6. < tag backtracking and cutting problems > lt.131 Split palindrome string

.NET基础知识快速通关9

Gamefi's new departure, aquanee will log in to gate and bitmart on June 9

flutter Dio示例

【转载】搞懂G1垃圾收集器

6.<tag-回溯和切割问题>lt.131.分割回文串
随机推荐
Golang access pin notification
PMP project management knowledge system
Origin 2022b | 更新及安装 | 中英文切换
Composition maximum area
.NET基础知识快速通关11
Rédaction de documents scientifiques
Relay alphafold! Star pharmaceutical science and technology released a new era of tbind opening molecular protein complex structure prediction
LR11安装报错:此计算机上缺少vc2005_sp1_with_atl_fix_redist,请安装所有缺少的必要组件,然后重新运行此安装。
7.<tag-回溯和子集问题>lt.70.子集 + lt.90.子集 II
11. < tag binary tree and BST foundation > lt.501 Mode in binary search tree
03 | definition of China Taiwan: what are we talking about when we talk about China Taiwan?
Excel | App_ Error in workbookactive cannot set the installed property of class addin
09 | the fourth step: the construction and delivery of the middle office
Redis data structure and introduction
Golang-RPC(七):如何调试gRPC服务
Common laboratory tools | preparation of experimental solution | molarity calculator
组成最大面积
SIGIR 2022 | CMI: micro video recommendation combining comparative learning and multi interest mining
Anonymous inner classes and local variables
curator - 创建客户端