Skip to content

Latest commit

 

History

History
28 lines (19 loc) · 1014 Bytes

File metadata and controls

28 lines (19 loc) · 1014 Bytes

此工程为ru-rocker/gokit-playground的精简版, 简化了部分代码, 添加了一些注释.

基本上与04.gokit-lorem-restful-client完全相同, 只不过 client 与 server 服务间的通信用 grpc 形式而非 restful.

先启动 server 服务

$ go run cmd/server/main.go
Starting server

然后启动 client 对 server 服务发起请求, 完成后 client 运行结束.

$ go run cmd/client/main.go
Concurrunt nota re dicam fias, sim aut pecco, die appetitum.

这一示例中有一个小bug, 在client/main.go中调用grpctransport.NewClient()时, 第二个参数(即服务名称)不应为Lorem, 这导致执行客户端时出现如下错误

rpc error: code = Unimplemented desc = unknown service Lorem
exit status 1

按照官方issueBad service name给出的解决方案, 将Lorem -> pb.Lorem成功解决.