Understanding the gRPC server and gRPC stub
If you closely observe Figure 10.1, you'll find that the gRPC server and gRPC stub are core parts of the implementation because gRPC is based on client-server architecture. Once you define the service, you can generate both service interfaces and the stub using the Protobuf compiler, protoc
, with the gRPC Java plugin. You'll find a practical example in the next chapter, Chapter 11, gRPC-based API Development and Testing.
The following types of files are generated by the compiler:
- Models: It generates all the messages (that is, models) defined in the service definition file that contains the Protobuf code to serialize, deserialize, and fetch the types of request and response messages.
- gRPC Java files: It contains the service base interface and stubs. The base interface is implemented and then used as a part of the gRPC server. Stubs are used by the clients for communication with the server.
First, you need...