知识卡片
共享状态独立成资源
共享状态是承载一次作业业务输入与结果的独立HTTP资源,不是让任务共同依赖一张内部数据库表。每个任务从中读取所需字段填表,并把结果以幂等更新写回;结束后归档。它与[[进度资源只报告执行]]分工不同。
调价示例保存currentPrice与updatedPrice,先核对当前价再写目标价,而不只保存“上涨百分比”,这样重复应用不会不断叠加。共享字段语义仍需事前约定;单靠共享URL与PUT不保证并发任务更新原子性。
结构图:
flowchart TD
A[读取共享状态资源] --> B[按任务表单映射输入]
B --> C[执行任务]
C --> D[写回结果到共享状态]
D --> E[其他任务读取所需状态]
E --> F[作业结束归档]
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 超媒体工作流 · 查看原书依据
Note that in the preceding example, the task was described using idempotent language. For example, the target property of the change is expressed as updatedPrice and not percentIncrease. This makes supporting repeating and reverting changes much easier.
参考来源
- 位置:《RESTful Web API Patterns and Practices Cookbook Connecting and Orchestrating Microservices and Distributed Data (Mike Amundsen)》第7章《超媒体工作流》§7.2(来源项目:book-sources;源文件:extracted/RESTful Web API Patterns and Practices Cookbook Connecting and Orchestrating Microservices and Distributed Data (Mike Amundsen)/_epub-src/OEBPS/ch07.xhtml)
- 结论依据:原文以共享状态是承载一次作业业务输入与结果的独立HTTP资源,不是让任务共同依赖一张内部数据库表的方式说明该用途;同节示例与讨论补充了卡内条件和边界。
- 原始内容:Note that in the preceding example, the task was described using idempotent language. For example, the target property of the change is expressed as updatedPrice and not percentIncrease. This makes supporting repeating and reverting changes much easier.