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

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

主站蜘蛛池模板: 平舆县| 友谊县| 汕头市| 寻甸| 芜湖县| 沂南县| 高青县| 睢宁县| 仪征市| 延寿县| 内丘县| 化德县| 广德县| 随州市| 宁乡县| 东山县| 辽源市| 巴彦淖尔市| 连南| 共和县| 济源市| 肇州县| 连平县| 儋州市| 临沭县| 天峻县| 汝南县| 桦川县| 平昌县| 海城市| 贡山| 桓台县| 浦北县| 裕民县| 镇平县| 同德县| 乳源| 肇东市| 永福县| 临潭县| 富平县|