Understanding GRPC clients
GRPC is a high performance RPC framework that is built using protocol buffers (https://developers.google.com/protocol-buffers) and HTTP/2 (https://http2.github.io). Creating a GRPC client in Go has a lot of the same intricacies as working with Go HTTP clients. In order to demonstrate basic client usage, it's easiest to also implement a server. This recipe will create a greeter
service, which takes a greeting and a name and returns the sentence <greeting> <name>!
. In addition, the server can specify whether to exclaim !
or not .
.
This recipe won't explore some details about GRPC such as streaming, but will hopefully serve as an introduction to creating a very basic server and client.
Getting ready
Configure your environment according to these steps:
- Refer to the Getting ready section of the Initializing, storing, and passing http.Client structs recipe in this chapter.
- Install GRPC at https://github.com/grpc/grpc/blob/master/INSTALL.md.
- Run the
go get github...