justtrackio / gosoline

Gosoline is our framework which fuels all of our Golang applications
MIT License
96 stars 50 forks source link

config: Implement preloading of config settings depending on sources #1133

Open bt-justtrack opened 4 months ago

bt-justtrack commented 4 months ago

The Idea is to already load the config from relevant settings into memory such that we dont need to eg resolve env vars on demand once we need them. This also ties in with #1132 . It is up for discussion on what env vars eg we would want to preload and how to technically solve that (eg. with a prefix, or just all env vars ?).

bt-justtrack commented 3 months ago

Plan: have a provider interface allowing resolution of a config key into a value. When requesting a value from config the providers are asked through a prioritized list if they have a value for a given key. If they do we use that value, if not we descend further down in priority. Providers can optionally also implement another interface allowing them to track usage for settings keys. Here you can ask them to return the list of used and unused settings keys. For eg the env var provider this usage tracking could be tracking all actually requested env vars and returning as unused the set of all env var keys - the set of requested keys.