Why gRPC #
The main usage scenarios:
Low latency, highly scalable, distributed systems.
Developing mobile clients which are communicating to a cloud server.
Designing a new protocol that needs to be accurate, efficient and language independent.
Layered design to enable extension eg. authentication, load balancing, logging and monitoring etc.
read more on FAQ
in simiple, (g)RPC lets client call functions of server by connection easily and efficiently
Prerequisites #
- tool
protoc
, download from the release page - protoc-gen-go: plugin of
protoc
, you must have $GOPATH and $GOBIN setting, and install it by command
go get -u github.com/golang/protobuf/protoc-gen-go
Usage #
e.g. google.golang.org/grpc/examples/helloworld
- edit .proto file
- generate language file, e.g. xx.go by tool
protoc
and pluginprotoc-gen-go
cd $GOPATH
go generate google.golang.org/grpc/examples/helloworld/...
- reimplement the proto.go genereated by protoc in server side
- update client side
- retry server and client, you will see the change