Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confused by the config hierarchy loading/caching model #8

Open
Omnikron13 opened this issue May 6, 2024 · 0 comments
Open

Confused by the config hierarchy loading/caching model #8

Omnikron13 opened this issue May 6, 2024 · 0 comments

Comments

@Omnikron13
Copy link

I'm struggling to understand the design/rationale behind how a config file hierarchy is intended to be handled here.

From what I can see, the design is that for every potential config option/key a new copy of the hierarchy of applicable config files, then when the config value is first accessed the files are read and unmarshalled until a config file with the setting is found, with the unmarshalled data cached for the next time that config value might be read?

The problem I'm having is, it seems like every chain is storing its own copy of the paths, and subsequently caching its own copy of the unmarshalled data?

While I can see potential merit in lazily processing the config files, the fact the data isn't centralised and is getting duplicated seems like a big problem. Aside from the obvious concerns of efficiency, if a config file (or file hierarchy) is getting read out once when value foo is first needed, and then again when value bar is first needed, then (assuming it is possible a config file could be changed during program execution) you could end up with an inconsistent and maybe invalid or even dangerous configuration state.

Also I've only skimmed over the entirety of the ValueSource/ValueSourceChain code just now, but it doesn't seem like there is anything in place there to prevent chains for duplicate keys being created there, so isn't it possible that somebody could pretty trivially create more than one config chain for the value foo, meaning that you could potentially end up with not only incompatibility between keys if config files get modified, but inconsistencies over what a given config value actually is in different places in a codebase.

Apologies if I'm just short on sleep and caffeine, and have missed something key in the design here. But to my reading right now it seems like there are pretty fundamental flaws in how config files are being read, processed, and cached, along with how the YAML() et. al. functions/API is designed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant