Generate Code from the Proto File

To generate code from the proto file, use a gRPC plug-in with protoc. This process generates client code, server code, and protocol buffer code for populating, serializing, and retrieving message types. For more information, see Introduction to gRPC in the gRPC documentation.

The quick starts walk you through the steps of generating the code from the proto file using gRPC tools.

The client has a local object known as a stub that implements the service methods. When a gRPC client calls the API, the corresponding API implementation is called on the server. The gRPC infrastructure decodes incoming requests, executes service methods, and encodes service responses. The client calls the methods on the local object, wrapping the parameters for the call in the appropriate protocol buffer message type. gRPC handles sending the requests to the server and returning the server’s protocol buffer responses.

The gRPC server serializes the response of a Subscribe RPC call based on the protocol buffer message type specified in the proto file. Similarly, when an event is published through one of the publish RPC methods, the publish request is serialized based on the protocol buffer message type. The payload of a published or received event is in the Avro binary format. For more information, see Protocol Buffers in the gRPC documentation and Event Data Serialization with Apache Avro.