知识卡片
服务实现与连接生命周期分工
gRPC服务端实现生成接口并注册到服务器,客户端建立连接后取得桩,再以带期限的上下文发起方法调用。连接建立的等待与单次业务调用的期限是两种预算,最后还要关闭连接。原稿Delete返回类型残留PutResponse且使用旧连接选项,教学理解应依据.proto契约,不能照抄为当前完整代码。
调用形态为注册生成接口实现,再用客户端桩的Get(ctx, request)等方法;本卡不提供未核验的当前连接选项范例。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Loose Coupling · 查看原书依据
each accepts a context.Context and a request pointer, and returns a response pointer and an error. Tip As a side-effect of its simplicity, it’s dead easy to mock requests to and responses from a gRPC server implementation. To implement our server, we’ll make use of a generated struct that provides a default implementation for the
参考来源
- 位置:《Cloud Native Go》第08章《Loose Coupling》(来源项目book-sources;源文件:extracted/Cloud Native Go (Matthew A. Titmus)/_epub-src/OEBPS/ch08.xhtml)
- 结论依据:gRPC服务端实现生成接口并注册到服务器,客户端建立连接后取得桩,再以带期限的上下文发起方法调用。原文相应定义、示例或限制为此结论提供依据;补充纠错与版本边界在正文就近标明。
- 原始内容:each accepts a context.Context and a request pointer, and returns a response pointer and an error. Tip As a side-effect of its simplicity, it’s dead easy to mock requests to and responses from a gRPC server implementation. To implement our server, we’ll make use of a generated struct that provides a default implementation for the