CSE 124 Lecture Notes - Lecture 12: Protocol Buffers

57 views3 pages
Google RPC (GRPC)
- Defines services (collection of RPC calls)
E.g. service Search {
rpc searchWeb(SearchRequest) returns (SearchResult) {}
}
- “single” invocation called searchWeb()
About gRPC:
- Exactly 1 argument
- Exactly 1 data type
IDL: Interface Definition Language
- language-neutral way of specifying:
- Data structures (called Messages)
- services, consisting of procedures/methods
Note: if you want to pass > 1 piece of data, pass it into your Message
Ex:
syntax = “proto3”; ← what “version” of protocol buffers
message SearchRequest {
string query = 1;
int32 page_number = 2;
int32 result_per_page = 3;
Note: these fields are specific to our IDL
IDL Positional Arguments
- Why do we label the fields with numbers?
- So we can change the signature of the message “later” and still be compatible w/ legacy
code
Protocol Buffers: Map Type
map<key_type, value_type> map_field = N;
Ex: map<string, Project> projects = 3;
Note: can also be recursively defined!
Implementing in Different Languages
IDL: message Person {
required string name = 1;
required int32 id = 2;
optional string email = 3;
}
Required vs optional: some fields can be made “required” or “optional”
In Java:
Unlock document

This preview shows page 1 of the document.
Unlock all 3 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers