Protocol Buffers 介紹

何謂 Protocol Buffers

Protocol buffers are a flexible, efficient, automated mechanism for serializing structured data.

  • The first step when working with protocol buffers is to define the structure for the data you want to serialize in a proto file: *.proto
// The greeter service definition.
service Greeter {
  // Sends a greeting
  rpc SayHello (HelloRequest) returns (HelloReply) {}
}

// The request message containing the user's name.
message HelloRequest {
  string name = 1;
}

// The response message containing the greetings
message HelloReply {
  string message = 1;
}

參考文件