valeriansaliou / bloom

:cherry_blossom: HTTP REST API caching middleware, to be used between load balancers and REST API workers.
https://crates.io/crates/bloom-server
Mozilla Public License 2.0
712 stars 48 forks source link

Unable to use environment variables in config #21

Closed Malanius closed 1 year ago

Malanius commented 1 year ago

Hello, I'd like to have the possibility to reference environment variables inside the configuration file. For now, it doesn't seem to work or I didn't figure out how to do that.

For example, I have bloom packed inside a docker container along with the backend and I'd like to reuse the same image on different environments and be able to configure the Redis host as each environment has its own cluster with REDIST_HOST env var. The rest of the backend configuration is done through environment variables (following the 12fa principles) and it would be great to have the same possibility in bloom as well.

For now, I can work around this by replacing some placeholder value in the config using entry point script, but that doesn't feel as clean and it's quite rare to find something that doesn't support configuration from env vars nowadays :slightly_smiling_face:

PS: I might be able to hack on this, but never done something in Rust before so I would need some pointers on how to deal with this.

valeriansaliou commented 1 year ago

Hello! Someone has already done a PR for Sonic, another Rust project of mine: https://github.com/valeriansaliou/sonic/pull/148

I'm accepting any PR on this if you're willing to work on it :) Note that I may have refactored the env var reader code in Sonic, so you may look at the env var parsing code from the master branch instead of the original PR I provided here.

Malanius commented 1 year ago

Thanks, that will be helpful! I'll take a look at how it's done in sonic and if it is something I could reimplement for bloom.