基于 go 的 gRPC 简介与实现
gRPC 简介
gRPC 使用 Protocol Buffer 作为其接口定义语言,使得 gRPC 客户端可以跨机器、跨语言调用 gRPC 服务器的方法。
Protocol Buffer 定义接口的输入参数和返回类型
gRPC 服务端:实现接口方法,并运行 gRPC Server
gRPC 客户端:调用 gRPC Stub (相当于 gRPC Server 在客户端的代理,拥有与 Server 实现的接口方法)的接口
环境安装
Mac 安装 go gRPC 所需环境
1 | brew install protobuf protoc-gen-go protoc-gen-go-grpc |