polymath icon indicating copy to clipboard operation
polymath copied to clipboard

Implement a more robust config store

Open dglazkov opened this issue 2 years ago • 12 comments

JSON config files are great for small-scale projects, but a more robust solution is needed for larger scale.

https://github.com/dglazkov/polymath-host uses Firestore, for example. Here's a path to get there, expressed as a set of interlocked patterns:

  • Configuration is accessed via *Config classes. Each class takes in a simple dict[str, str] and offers simple accessors with good defaults and type conversion if necessary. For example, HostConfig, InfoConfig, etc.
  • The dictionary is produced by the *ConfigStore class. The class is not specialized to each kind of config, it's just a way to read the store. It is specialized for the type of storage: JSONConfigStore, FirestoreConfigStore, etc.
  • Each *Config class has a create class method that takes a *ConfigStore class to produce the right instance.

(to be continued)

dglazkov avatar Feb 05 '23 18:02 dglazkov