← 返回刚才阅读的位置

知识卡片

操作参考卡 · 4545.d.14

契约分别描述消息与方法

理解等级:中级

Protobuf的message描述数据,字段有类型、名字和稳定编号,repeated表示零个或多个值;rpc描述使用这些消息的动作。例如message GetRequest { string key = 1; }定义输入,rpc Get(GetRequest) returns (GetResponse);定义一次请求对应一次响应的方法。两者合成服务契约,不能把生成接口当作已实现业务逻辑。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • Loose Coupling · 查看原书依据

      the rpc definitions represent functions — verbs — which will send and receive messages — nouns. In this example, we add three methods to our service: Get which accepts a GetRequest and returns a GetResponse, Put which accepts a PutRequest and returns a PutResponse, and Delete which accepts a DeleteRequest and returns a DeleteResponse. Note

    参考来源

    - 位置:《Cloud Native Go》第08章《Loose Coupling》(来源项目book-sources;源文件:extracted/Cloud Native Go (Matthew A. Titmus)/_epub-src/OEBPS/ch08.xhtml) - 结论依据:Protobuf的message描述数据,字段有类型、名字和稳定编号,repeated表示零个或多个值;rpc描述使用这些消息的动作。原文相应定义、示例或限制为此结论提供依据;补充纠错与版本边界在正文就近标明。 - 原始内容:the rpc definitions represent functions — verbs — which will send and receive messages — nouns. In this example, we add three methods to our service: Get which accepts a GetRequest and returns a GetResponse, Put which accepts a PutRequest and returns a PutResponse, and Delete which accepts a DeleteRequest and returns a DeleteResponse. Note