返回主题:引擎运行时与状态管理

知识卡片

问题卡 · 1870.b.11

直接撤销受历史与权限约束

理解等级:高级

底层没有撤销动作时,接口可把已执行动作及必要历史按contextId持久记录,再用公开反向操作撤回,例如删除刚创建的资源。撤销还要检查适用时间和调用者是否具备反向操作权限。

这适合影响明确的简单CRUD,不意味着跨服务恢复到精确旧状态。时间窗口只能缩小风险,不能证明无人依赖新状态。多服务副作用不清楚时,可考虑[[延时撤销在提交前取消]];不能把本地反向调用冒充全局事务。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 超媒体工作流 · 查看原书依据

      For simple CRUD-style services, implementing an undo is pretty straightforward. You need to implement the service action (e.g., updateCustomer), keep a history of undoable actions in a local durable storage index by an identifier (contextId), and expose your own external action (for example, undoUpdateCustomer that takes the contextId). When implementing your local undo functionality, it is wise to establish a time frame for valid rollbacks.

    参考来源

    - 位置:《RESTful Web API Patterns and Practices Cookbook Connecting and Orchestrating Microservices and Distributed Data (Mike Amundsen)》第7章《超媒体工作流》§7.17(来源项目:book-sources;源文件:extracted/RESTful Web API Patterns and Practices Cookbook Connecting and Orchestrating Microservices and Distributed Data (Mike Amundsen)/_epub-src/OEBPS/ch07.xhtml) - 结论依据:原文以底层没有撤销动作时,接口可把已执行动作及必要历史按contextId持久记录,再用公开反向操作撤回,例如删除刚创建的资源的方式说明该用途;同节示例与讨论补充了卡内条件和边界。 - 原始内容:For simple CRUD-style services, implementing an undo is pretty straightforward. You need to implement the service action (e.g., updateCustomer), keep a history of undoable actions in a local durable storage index by an identifier (contextId), and expose your own external action (for example, undoUpdateCustomer that takes the contextId). When implementing your local undo functionality, it is wise to establish a time frame for valid rollbacks.