知识卡片
超时只限制调用方等待
超时使调用者不再无限等候。若底层接受Context,应传递截止时间并由其协作停止;若包装不接受取消的第三方函数,调用者虽可返回,底层仍可能运行。原书无缓冲结果通道在超时后可能无接收者,使后台发送阻塞;需要明确结果丢弃、取消与工作生命周期,不能把包装等同于终止。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Cloud Native Patterns · 查看原书依据
Timeout represents a common solution to this dilemma, and is so beautifully simple that it barely even qualifies as a pattern at all: given a service request or function call that’s running for a longer-than-expected time, the caller simply… stops waiting. However, don’t mistake “simple” or “common” for “useless”. On the contrary, the ubiquity of
参考来源
- 位置:《Cloud Native Go》第04章《Cloud Native Patterns》(来源项目book-sources;源文件:extracted/Cloud Native Go (Matthew A. Titmus)/_epub-src/OEBPS/ch04.xhtml)
- 结论依据:超时使调用者不再无限等候。原文相应定义、示例或限制为此结论提供依据;补充纠错与版本边界在正文就近标明。
- 原始内容:Timeout represents a common solution to this dilemma, and is so beautifully simple that it barely even qualifies as a pattern at all: given a service request or function call that’s running for a longer-than-expected time, the caller simply… stops waiting. However, don’t mistake “simple” or “common” for “useless”. On the contrary, the ubiquity of