gRPC First Look

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 #

  1. tool protoc, download from the release page
  2. 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

  1. edit .proto file
  2. generate language file, e.g. xx.go by tool protoc and plugin protoc-gen-go

cd $GOPATH
go generate google.golang.org/grpc/examples/helloworld/...
  1. reimplement the proto.go genereated by protoc in server side
  2. update client side
  3. retry server and client, you will see the change

2017-12-10