找回密码
 立即注册
查看: 181|回复: 0

Proto3: Defining Services - 定义服务

[复制链接]
发表于 2022-11-19 15:34 | 显示全部楼层 |阅读模式
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
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Unity开发者联盟 ( 粤ICP备20003399号 )

GMT+8, 2024-11-24 19:59 , Processed in 0.178148 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表