← 返回刚才阅读的位置

知识卡片

普通读书笔记卡 · 3938.a.9

幂等写应区分丢响应

理解等级:中级

幂等写表示相同请求重复执行,目标资源仍处于同一预期状态;并不保证每次响应相同。网络故障可能发生在写入之前,也可能只是成功响应丢失,客户端无法仅靠超时区分。稳定资源标识加替换式PUT,使重发无需变成第二次新增。

这是一项接口与实现共同兑现的承诺,不能只换HTTP方法就让业务副作用自动幂等。重试应有上限,持续失败记录并停止;并发写还需要[[条件写保护资源版本]]。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 分布式数据 · 查看原书依据

      Another possible error condition is a network failure. In this case, either the update never reaches the server or the server’s response never reaches the client. You can think of this as the “lost response problem”. Fixing this problem is easier, if not more reliable. The API client can simply resend the existing request in hopes that the server is once again reachable.

    参考来源

    - 位置:《RESTful Web API Patterns and Practices Cookbook Connecting and Orchestrating Microservices and Distributed Data (Mike Amundsen)》第6章《分布式数据》§6.2(来源项目:book-sources;源文件:extracted/RESTful Web API Patterns and Practices Cookbook Connecting and Orchestrating Microservices and Distributed Data (Mike Amundsen)/_epub-src/OEBPS/ch06.xhtml) - 结论依据:原文以幂等写表示相同请求重复执行,目标资源仍处于同一预期状态;并不保证每次响应相同的方式说明该用途;同节示例与讨论补充了卡内条件和边界。 - 原始内容:Another possible error condition is a network failure. In this case, either the update never reaches the server or the server’s response never reaches the client. You can think of this as the “lost response problem”. Fixing this problem is easier, if not more reliable. The API client can simply resend the existing request in hopes that the server is once again reachable.