Closed adevore closed 5 days ago
hi! thanks for this! we kinda steered away from figment and the like. the reason is that it is hard to reason about where config comes from, which creates a mental friction and this is typical in such config libs not only in Rust but in other languages. so, we decisively limited how config "layering" works in this way:
get_env
pull what ever you want from ENV (you can use what ever tooling you want to inject to env, advanced, or not a-la 12-factor apps)so some kind of flexibility allowed but mostly -- flat is king.
I think to still extract some insights here maybe you can give some concrete examples where you bumped into a wall, i'm genuinely interested to see what we missed
Feature Request
Web servers often benefit from pulling configuration from multiple sources. For example, most configuration may be included in the main repository, while secrets are in a separate repository and environmental variables are used as overrides. I frequently use Dynaconf for this in Python.
Currently, a limited form of this is possible with the Tera template engine with
get_env
and a default. However, setting it up is tedious. Also, usingget_env
alone only works with environmental variables.There are two alternatives in the Rust ecosystem, config and figment. I don't have experience with either one, but I'm willing to put some time into researching if this is a possibility. Config has some built-in async support included, but I'm not sure how important that is in practice. Figment has some tricks that look handy for testing. It also has more extensive docs.