Skip to content

Re-thinking: Layering of configuration #324

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

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

Re-thinking: Layering of configuration #324

matthiasbeyer opened this issue Apr 23, 2022 · 3 comments

Comments

@matthiasbeyer
Copy link
Member

We currently (as of 0.13.x) support layering of configuration objects to merge configuration values.

This should be supported in the future as well.


Re-Thinking the layering mechanism

We might re-think the idea of layering a bit here.
Right now (AFAICR) the layering is executed on loading of the configuration. In future, we might implement this as an operation that happens on accessing the values.
This way, we would always keep all values from the sources and only "merge" the values when accessing a certain element.

Example:

# 1.toml
foo = 1
bar = 2
# 2.toml
bar = 3
// pseudo code:
Build config object
Register "1.toml"
Register "2.toml"
Access config at "bar"
  - Mechanism finds out that "bar" is from "2.toml" and its value is 3
@szarykott
Copy link
Contributor

szarykott commented May 8, 2022

As much as it would be great for debugging purposes, it might impair performance of the solution. Is this proposal motivated by some real life problems that is solves?

EDIT: I've read linked issue.

@dnaka91, would it be enough if sources of configuration were traced on the builder level, but not on Config level? Taking a look at the code, I am wondering if this is not possible right now, via Debug print of the builder.

@matthiasbeyer
Copy link
Member Author

As much as it would be great for debugging purposes, it might impair performance of the solution. Is this proposal motivated by some real life problems that is solves?

No, I am just thinking from the ground up how this crate could look like in the future.

@matthiasbeyer matthiasbeyer mentioned this issue Sep 17, 2022
15 tasks
@martinvonz
Copy link
Contributor

Another benefit of preserving the layering after load-time is that the client application can iterate over the layers and print the configs in each layer. That came up in jj-vcs/jj#917 (comment)

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

4 participants