|
If you want to use your message types with an RPC (Remote Procedure Call) system, you can define an RPC service interface in a .proto file and the protocol buffer compiler will generate service interface code and stubs in your chosen language. So, for example, if you want to define an RPC service with a method that takes your SearchRequest and returns a SearchResponse, you can define it in your .proto file as follows:
如果你想将你的message类型应用于RPC(远程程序调用)系统。你可以在.proto文件中定义一个RPC服务接口,protocol buffer编译器会根根据你所选择的语言生成服务接口代码和存根。举个例子,如果你想定义一个RPC服务,该服务提供了一个调起SearchRequest并返回一个SearchResponse的方法,你就可以在你的.proto文件中像下边这样定义:
service SearchService { rpc Search(SearchRequest) returns (SearchResponse);}
The most straightforward RPC system to use with protocol buffers is gRPC: a language- and platform-neutral open source RPC system developed at Google. gRPC works particularly well with protocol buffers and lets you generate the relevant RPC code directly from your .proto files using a special protocol buffer compiler plugin.
和protocol buffer一起使用的最直接的RPC系统是gRPC:一种语言无关、平台无关的由Google开发的开源RPC系统。gRPC和protocol buffers配合的很好,并且利用一个特殊protocol buffer编译器插件可以让你直接从你的.proto文件生成相关的RPC代码。
If you don't want to use gRPC, it's also possible to use protocol buffers with your own RPC implementation. You can find out more about this in the Proto2 Language Guide.
如果你不想使用gRPC,你自己的RPC实现中使用protocol buffers也是可行的。你可以在Proto2 语言指南中查看更多有关这个的信息。
There are also a number of ongoing third-party projects to develop RPC implementations for Protocol Buffers. For a list of links to projects we know about, see the third-party add-ons wiki page.
也有很多进行中的三方项目在为Protocol Buffers开发RPC实现。我们知道的项目链接列表,参阅third-party add-ons wiki page |
|