Grpc Mock

项目地址

https://github.com/tokopedia/gripmock

编写proto

vim /home/monitor/pd/hello.proto

 1syntax = "proto3";
 2
 3package hello;
 4
 5// The greeting service definition.
 6service Greeter {
 7    // Sends a greeting
 8    rpc SayHello (HelloRequest) returns (HelloReply) {}
 9}
10
11// The request message containing the user's name.
12message HelloRequest {
13    string name = 1;
14}
15
16// The response message containing the greetings
17message HelloReply {
18    string message = 1;
19}

启动mock服务

1docker run -p 4770:4770 -p 4771:4771 -v /home/monitor/pd:/proto tkpd/gripmock /proto/hello.proto

建立mock接口数据

1curl -X POST -d '{"service":"Greeter","method":"SayHello","input":{"equals":{"name":"gripmock"}},"output":{"data":{"message":"Hello GripMock"}}}' 192.168.41.131:4771/add

使用grpc调试工具(bloomrpc)请求

参数:

1{
2  "name": "gripmock"
3}

发布日期:2023-03-27 21:42 字数:94 用时 1分钟
tags:Grpc Mock