GRPC调试工具:grpcurl安装及使用

grpcurl 安装

macos

brew install grpcurl

linux

sudo apt-get install -y grpc
sudo apt-get install -y grpc-doc

列出服务

~ $ grpcurl -plaintext localhost:9770 list
api.mytool.Master
grpc.channelz.v1.Channelz
grpc.health.v1.Health
grpc.reflection.v1.ServerReflection
grpc.reflection.v1alpha.ServerReflection
kratos.api.Metadata

查看服务的接口

~ $ grpcurl -plaintext localhost:9770 list api.mytool.Master
api.mytool.Master.Action
api.mytool.Master.CreateTask
api.mytool.Master.DeployTask
api.mytool.Master.Ping
api.mytool.Master.WorkerServer

查看接口定义

~ $ grpcurl -plaintext localhost:9770  describe api.mytool.Master.DeployTask
api.mytool.Master.DeployTask is a method:
rpc DeployTask ( .api.mytool.DeployTaskRequest ) returns ( .api.mytool.DeployTaskReply ) {
  option (.google.api.http) = { post: "/master/task/deploy", body: "*" };
}

查看接口参数定义

~ $ grpcurl -plaintext localhost:9770  describe api.mytool.DeployTaskRequest
api.mytool.DeployTaskRequest is a message:
message DeployTaskRequest {
  string host = 1;
  int64 task_id = 2;
}

请求服务接口

~ $ grpcurl -plaintext -d '{"host":"all", "task_id":10}' localhost:9770  api.mytool.Master.DeployTask
{
  "header": {
    "reason": "SUCCESS",
    "message": "响应正常"
  },
  "data": {
    "results": [
      {
        "host": "localhost:9870",
        "sn": "worker1",
        "status": "success",
        "message": "Success",
        "reason": "SUCCESS"
      }
    ]
  }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值