https://github.com/fullstorydev/grpcurl
Install:
go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest
Add code to enable server reflection:
import "google.golang.org/grpc/reflection" reflection.Register(s) // s is a grpc server
In Makefile:
srvaddr=0.0.0.0:50051 gcurl: grpcurl -cacert ./certs/ca_cert.pem \ -authority "check.test.example.com" \ -reflect-header 'auth_token: authd' \ $(srvaddr) $(command)
Run grpcurl with Makefile:
zzh@ZZHPC:/zdata/Github/zgrpc-go-professionals$ make command=list gcurl grpcurl -cacert ./certs/ca_cert.pem \ -authority "check.test.example.com" \ -reflect-header 'auth_token: authd' \ 0.0.0.0:50051 list grpc.reflection.v1.ServerReflection grpc.reflection.v1alpha.ServerReflection todo.v2.TodoService zzh@ZZHPC:/zdata/Github/zgrpc-go-professionals$ make command="describe todo.v2.TodoService" gcurl grpcurl -cacert ./certs/ca_cert.pem \ -authority "check.test.example.com" \ -reflect-header 'auth_token: authd' \ 0.0.0.0:50051 describe todo.v2.TodoService todo.v2.TodoService is a service: service TodoService { rpc AddTask ( .todo.v2.AddTaskRequest ) returns ( .todo.v2.AddTaskResponse ); rpc DeleteTasks ( stream .todo.v2.DeleteTasksRequest ) returns ( stream .todo.v2.DeleteTasksResponse ); rpc ListTasks ( .todo.v2.ListTasksRequest ) returns ( stream .todo.v2.ListTasksResponse ); rpc UpdateTasks ( stream .todo.v2.UpdateTasksRequest ) returns ( .todo.v2.UpdateTasksResponse ); }
标签:reflection,GRPC,0.0,interact,TodoService,grpcurl,v2,todo From: https://www.cnblogs.com/zhangzhihui/p/18188186