polymath
polymath copied to clipboard
Implement a more robust config store
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 simpledict[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 acreate
class method that takes a*ConfigStore
class to produce the right instance.
(to be continued)