知识卡片

问题卡 · 3332.e.3

显隐字段支持模型演进

理解等级:中级

生产中的数据模型需要增加字段或回退版本时,严格模式可能迫使所有消费者同步升级。

显式字段位于固定模式中,隐式字段放入预留的名称值集合,例如nvp:[{name:"middleName",value:"Seymore"}]。新增数据先放扩展集合,可减少同步修改所有消费者模式的压力;回退服务版本时也能保留已收集的新数据。

统一访问函数先找显式字段,再找扩展集合,使字段以后升格为显式字段时调用方式保持一致。代价是读写规则更复杂,隐式字段的名称和值同样必须验证。此模式主要用于内部建模,外部仍应采用稳定消息格式。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

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

      A good way to build in model changes for your data storage is to adopt a two-tier approach to modeling data through the use of explicit and implicit data properties. Explicit fields are part of the model or schema (e.g., {"familyName" : "Quarkus"}). Implicit fields are part of a name-value collection associated with the model (e.g., {"nvp": [{ "name": "familyName", "value": "Quarkus" }]}).

    参考来源

    - 位置:《RESTful Web API Patterns and Practices Cookbook Connecting and Orchestrating Microservices and Distributed Data (Mike Amundsen)》第6章《分布式数据》§6.10(来源项目:book-sources;源文件:extracted/RESTful Web API Patterns and Practices Cookbook Connecting and Orchestrating Microservices and Distributed Data (Mike Amundsen)/_epub-src/OEBPS/ch06.xhtml) - 结论依据:原文以显式字段位于固定模式中,隐式字段放入预留的名称值集合,例如`nvp:[{name:"middleName",value:"Seymore"}]`的方式说明该用途;同节示例与讨论补充了卡内条件和边界。 - 原始内容:A good way to build in model changes for your data storage is to adopt a two-tier approach to modeling data through the use of explicit and implicit data properties. Explicit fields are part of the model or schema (e.g., {"familyName" : "Quarkus"}). Implicit fields are part of a name-value collection associated with the model (e.g., {"nvp": [{ "name": "familyName", "value": "Quarkus" }]}).