azos icon indicating copy to clipboard operation
azos copied to clipboard

Why is `ConfigVector` a sealed class? Why is it not possible to extend it with business config validation? Also provide accessor to build its config content in a structured way?

Open g8sun opened this issue 2 years ago • 1 comments

g8sun avatar Aug 11 '21 17:08 g8sun

It is a sealed class because it was meant to prevent the extension for these reasons:

  • if you need to store complex business entity - use Typed data documents. Otherwise how would a caller know what schema is expected by the field? while possible to do it leads to complexity
  • The fact that you need to use configuration nodes is because you want to execute merge/override which configuration supports, but that is a STORAGE concern, this not a concern of user/consumer strictly speaking

What you need to do instead: a. In you public APi models, expose not ConfigVector but custom-derived type from FragmentModel, this way the caller gets schema, validation and all other standard plumbing b. Implement Configure(node) and PersistConfiguration(node) on your custom FragmentModel- those can build config nodes and read themselves from config back- c. store Configuration content in your db using ConfigVector,

To summarize:

  • ConfigVector should not typically be used on public API models, unless you need to hand config to API as is (a rare case)
  • Use data documents (e.g. FragmentModels) for business API modeling
  • The configuration content is mostly storage concern. Use ConfigVector in storage layer

itadapter avatar Aug 17 '21 17:08 itadapter