知识卡片
替换值使批处理可重放
对[[涨价批处理重放风险]],把消息改为productId,currentPrice,newPrice。服务只有在当前价格仍等于currentPrice时才写入newPrice,否则跳过该记录;重放不会再次叠加百分比。书中也给出仅传productId与newPrice的替代方式,适合直接重复设置最终值的语义。比较与写入应按完整业务条件实现,不能只靠PUT字样保证安全。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 超媒体接口设计 · 查看原书依据
Notice that this update message includes the productId, currentPrice, and newPrice properties. Now this action can safely be repeated. The service can check to see if the catalog price for a particular productId is set to currentPrice before applying the newPrice value. Otherwise, the operation can skip the price update for that record and move on to the next.
参考来源
- 位置:《RESTful Web API Patterns and Practices Cookbook Connecting and Orchestrating Microservices and Distributed Data (Mike Amundsen)》第03章《超媒体接口设计》(来源项目 book-sources;源文件:extracted/RESTful Web API Patterns and Practices Cookbook Connecting and Orchestrating Microservices and Distributed Data (Mike Amundsen)/_epub-src/OEBPS/ch03.xhtml;小节:3.8)
- 结论依据:原文以对[[涨价批处理重放风险]],把消息改为productId,currentPrice,newPrice的机制或场景为依据;同小节余文补充本卡所列条件,按2022年原书语境整理。
- 原始内容:Notice that this update message includes the productId, currentPrice, and newPrice properties. Now this action can safely be repeated. The service can check to see if the catalog price for a particular productId is set to currentPrice before applying the newPrice value. Otherwise, the operation can skip the price update for that record and move on to the next.