Project 4 Flashcards
WHat is Protocol Buffers
Protocol buffers are Google’s language-neutral, platform-neutral, extensible mechanism for serializing structured data – think XML, but smaller, faster, and simpler. You define how you want your data to be structured once, then you can use special generated source code to easily write and read your structured data to and from a variety of data streams and using a variety of languages.
RPC service
An RPC service is a collection of message types and remote methods that provide a structured way for external applications to interact with web applications
How to define the RPC service
- Define the message types used for requests and responses 2. Define the services interface that receive the request and sen the responses using the message types. Each service has its methods
.
- . gRPC works particularly well with protocol buffers and lets you generate the relevant RPC code directly from your .proto files using a special protocol buffer compiler plugin.
Steps to create application that uses RPC
- Define message formats and services interface in a .proto file. 2. Run the protocol buffer compiler to compile the code. Generate C++ code you need to work with the message types. The .proto files are the input 3. Use the C++ protocol buffer API to write and read messages. This is creating files in C++ that import the code in the previous step from the compilation and that uses it to read and write
Why Use Protocol Buffers?
- solve serialize and retrieve structured data - With protocol buffers, you write a .proto description of the data structure you wish to store. From that, the protocol buffer compiler creates a class that implements automatic encoding and parsing of the protocol buffer data with an efficient binary format. The generated class provides getters and setters for the fields that make up a protocol buffer and takes care of the details of readi
Why gRPC uses Protocol Buffers
Interface Definition Language (IDL) and as its underlying message interchange format.
Benefits of gRPC
- you can easily create a gRPC server in Java with clients in Go, Python, or Ruby
What is the stub in gRPC?
On the client side, the client has a stub (referred to as just a client in some languages) that provides the same methods as the server.
How gRPC uses protocol buffers
gRPC uses protoc with a special gRPC plugin to generate code from your proto file: you get generated gRPC client and server code, as well as the regular protocol buffer code for populating, serializing, and retrieving your message type
Diagram of how the gRPC server and clients intereact
Proto3 accessor methods Singular String Fields
Proto3 accessor methods Singular Numeric Fields
Step 1 gRPC tutorial
define the gRPC service and the method request and response types using protocol buffers
What code is generated by protoc