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

Re-thinking: Config sources #323

Closed
Tracked by #376
matthiasbeyer opened this issue Apr 23, 2022 · 3 comments
Closed
Tracked by #376

Re-thinking: Config sources #323

matthiasbeyer opened this issue Apr 23, 2022 · 3 comments

Comments

@matthiasbeyer
Copy link
Member

matthiasbeyer commented Apr 23, 2022

We want to support different sources of configuration.

These sources might be "sync" or "async" and should be abstracted via a trait mechanism.

What sources do we want to have?

Some "default" sources might be shipped with the crate:

  • Filesystem (sync)
  • Filesystem (async with tokio)
  • Environment

These sources can be compiletime feature-gated.

What a source should support

A "conifguration value source" should support several things:

  • Deserializing into an (internal, common) format
  • Updating the already-fetched configuration values
  • A human-readable description where the configuration values came from
    • To be able to construct nice error messages if necessary

More?

@matthiasbeyer matthiasbeyer changed the title Re-thinking: Support sync and async config sources Re-thinking: Config sources Apr 23, 2022
@matthiasbeyer
Copy link
Member Author

I finally found a bit of motivation to work on this.

What I thought of is that providing both sync and async readers from within this crate is likely causing a lot of pain down the road. I'd rather provide building blocks so that users of the crate can build their own readers (sync or async) and provide some default sync ones. For example, reading a string to a config should be easy. If that is easy, reading from a file is easy as well (either sync or async).

@jpmckinney
Copy link

reading a string to a config should be easy

Is this already doable, or is it part of #376? (Similarly, reading from a BufRead / BufReader.)

@matthiasbeyer
Copy link
Member Author

This is already possible. It just was written down so we could have a plan! The part that might needs working around is the async part - config-rs is not natively able to work with async config sources... you might need to fiddle a bit for this 😆

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

No branches or pull requests

2 participants