protobuf规范
message SearchRequest { string query = 1; int32 page_number = 2; int32 result_per_page = 3; }message SearchRequest { string query = 1; int32 page_number = 2; int32 result_per_page = 3; enum Corpus { UNIVERSAL = 0; WEB = 1; IMAGES = 2; LOCAL = 3; NEWS = 4; PRODUCTS = 5; VIDEO = 6; } Corpus corpus = 4; }
message Result { string url = 1; string title = 2; repeated string snippets = 3; // 代表[]string数组 }
message SampleMessage { oneof test_oneof { string name = 4; SubMessage sub_message = 9; } }
message SearchResponse { message Result { string url = 1; string title = 2; repeated string snippets = 3; } repeated Result results = 1; } message SomeOtherMessage { SearchResponse.Result result = 1; }
service SearchService { rpc Search(SearchRequest) returns (SearchResponse); }
package foo.bar; message Open { ... } message Foo { ... foo.bar.Open open = 1; ... }
import "myproject/other_protos.proto";
Last updated