July 2019
Intermediate to advanced
502 pages
14h
English
gRPC requires that you define a contract for your service in a special DSL inspired by protocol buffers. It is pretty intuitive and lets gRPC generate a lot of boilerplate code for you. I chose to locate the contract and the generated code in a separate top-level directory called pb (common short name for protocol buffers) because different parts of the generated code will be used by services and consumers. In these cases, it is often best to put the shared code in a separate location and not arbitrarily throw it into the service or the client.
Here is the pb/new-service/pb/news.proto file:
syntax = "proto3"; package pb; import "google/protobuf/timestamp.proto"; service News { rpc GetNews(GetNewsRequest) ...