知识卡片
入队响应公开处理进度
依赖暂不可用但可延后执行时,可本地保存请求,恢复后重放,并向消费者返回202及可监控处理进度的表示。必须把这种可能性写入接口契约,让消费者区分已受理与已完成。
对应[[支付入队牵连其他步骤]],调用者才能据进度决定等待、取消或协调其他动作。该方案增加队列、处理代码及请求历史维护;最终无法完成时仍要明确失败,并提供调用者需要的回退相关信息,不能无限保留请求而不反馈。
关联:[[为每项依赖准备退路]]。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 超媒体服务 · 查看原书依据
Typically, the initial response in this case is an HTTP 202 Accepted with a response body that describes details on how the API consumer can monitor the handling of the delayed request (see Recipe 7.15). Of course, you’ll need to include this possibility in your documented interface design so that API consumers can be prepared for this kind of response.
参考来源
- 位置:《RESTful Web API Patterns and Practices Cookbook》第5章《Hypermedia Services》(来源项目book-sources:extracted/RESTful Web API Patterns and Practices Cookbook Connecting and Orchestrating Microservices and Distributed Data (Mike Amundsen)/_epub-src/OEBPS/ch05.xhtml,配方5.16)
- 结论依据:原文以202及可监控延后处理的响应作为入队方案,并要求将这种可能性列入接口文档。
- 原始内容:Typically, the initial response in this case is an HTTP 202 Accepted with a response body that describes details on how the API consumer can monitor the handling of the delayed request (see Recipe 7.15). Of course, you’ll need to include this possibility in your documented interface design so that API consumers can be prepared for this kind of response.