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

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/.

主站蜘蛛池模板: 芜湖市| 万荣县| 永春县| 班玛县| 高台县| 文昌市| 济宁市| 濉溪县| 临城县| 岳普湖县| 图木舒克市| 华亭县| 七台河市| 华亭县| 南城县| 都兰县| 博野县| 巴南区| 绥芬河市| 张家口市| 保山市| 诏安县| 连南| 新乡县| 专栏| 寿光市| 安岳县| 武川县| 阳东县| 西乡县| 五原县| 红河县| 平定县| 阿拉善盟| 耒阳市| 紫金县| 绵阳市| 乌恰县| 买车| 轮台县| 宝鸡市|