← 返回刚才阅读的位置

知识卡片

问题卡 · 1765.j

查询元数据帮助修正

理解等级:中级

只有结果列表时,调用方难以判断查询质量、是否被限量以及如何改进。

查询响应除结果外,还可返回执行时间、执行时刻、返回条数、估计总数、状态、建议与重放链接,帮助调用方判断结果是否被限量、是否太宽以及如何调整。少量信息可随响应,较多时链接独立元数据资源。

应按消费者需要选择字段,避免暴露实际SQL、内部数据源或调试信息。q-status等是本书使用的自定义命名,需文档化,并非注册HTTP头或通用标准。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

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

      For most data queries, it is not enough to just return the resulting data. It can also be important to return metadata about the query to help client applications that made the request better understand the quality and usefulness of the returned data. In this section, we show a set of metadata values that should be considered as part of the response representation for HTTP queries (see Figure 6-3).

    参考来源

    - 位置:《RESTful Web API Patterns and Practices Cookbook Connecting and Orchestrating Microservices and Distributed Data (Mike Amundsen)》第6章《分布式数据》§6.5(来源项目:book-sources;源文件:extracted/RESTful Web API Patterns and Practices Cookbook Connecting and Orchestrating Microservices and Distributed Data (Mike Amundsen)/_epub-src/OEBPS/ch06.xhtml) - 结论依据:原文以查询响应除结果外,还可返回执行时间、执行时刻、返回条数、估计总数、状态、建议与重放链接,帮助调用方判断结果是否被限量、是否太宽以及如何调整的方式说明该用途;同节示例与讨论补充了卡内条件和边界。 - 原始内容:For most data queries, it is not enough to just return the resulting data. It can also be important to return metadata about the query to help client applications that made the request better understand the quality and usefulness of the returned data. In this section, we show a set of metadata values that should be considered as part of the response representation for HTTP queries (see Figure 6-3).