官术网_书友最值得收藏!

Protocol Buffers

Protocol Buffers are a Google product, and they have just entered their third revision. Protocol Buffers take the approach of providing a DSL that the generator (written in C) reads and can generate client and server stubs for over ten languages, the primary ten are maintained by Google and encompass: Go, Java, C, JavaScript for NodeJS.

Protocol Buffers is a pluggable architecture, so it is possible to write your own plugins to generate all kinds of endpoints not just RPC; however, RPC is the main use case as they are coupled to the gRPC framework.

gRPC was designed by Google to be a fast and language agnostic RPC framework, which originated from an internal project where latency and speed were of the utmost importance in Google's architecture. By default, gRPC uses protocol buffers as the method for serializing and de-serializing structured data. An example of this DSL is shown in the following example.

Protocol buffer service definition:

service Users { 
rpc CreateUser (User) returns (Error) {}
}

message User {
required string name = 1;
required int32 id = 2;
optional string email = 3;
}

message Error {
optional code int32 = 1
optional detail string = 2
}

Find more information on Protocol Buffers at https://developers.google.com/protocol-buffers/.

主站蜘蛛池模板: 德令哈市| 洮南市| 娄烦县| 九龙县| 正安县| 汝城县| 广东省| 灵川县| 临高县| 科技| 揭东县| 邳州市| 安陆市| 舟山市| 岳池县| 潍坊市| 芜湖县| 广西| 乐昌市| 江门市| 庄浪县| 和静县| 太谷县| 海林市| 新丰县| 平果县| 太康县| 南和县| 互助| 且末县| 长沙县| 景德镇市| 宣城市| 贡山| 淄博市| 青浦区| 红桥区| 黔江区| 历史| 渑池县| 九寨沟县|