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

Multiple Sources #62

Open
Sparky983 opened this issue Jul 27, 2024 · 0 comments · May be fixed by #63
Open

Multiple Sources #62

Sparky983 opened this issue Jul 27, 2024 · 0 comments · May be fixed by #63
Assignees
Labels
feature API additions proposal To propose features that aren't fully fleshed out (and may be dropped)
Milestone

Comments

@Sparky983
Copy link
Owner

Sparky983 commented Jul 27, 2024

Motivation

It is common to "override" configured values from other sources such as the system properties or environment variables. Now that #55 is implemented, ConfigurationNodes can be dynamic and even represent multiple types ("10" can be both the string "10" and the number 10).

This used to exist until it was reverted in 285a2a5 due to a bad implementation that didn't combine different sources.

Proposal

Allow ConfigurationBuilder.source(ConfigurationSource) calls to be chained to add additional sources. Deserializers will then receive a merged configuration that combines all sources.

@Configuration
interface MyConfiguration {
  @Property("property")
  String property();
}
property = props
property: yaml
 // the first source is prioritized - this is what the original implementation did, but was it the right choice?
MyConfiguration configuration = Warp.builder(MyConfiguration.class)
    .source(props)
    .source(yaml)
    .build();

assert configuration.property().equals("props");

Implementation

Implement a composite ConfigurationNode that combines several nodes then use that when calling the configuration deserializer.

@Sparky983 Sparky983 added feature API additions proposal To propose features that aren't fully fleshed out (and may be dropped) labels Jul 27, 2024
@Sparky983 Sparky983 self-assigned this Jul 27, 2024
@Sparky983 Sparky983 linked a pull request Jul 28, 2024 that will close this issue
@Sparky983 Sparky983 added this to the 0.1 milestone Oct 2, 2024
@Sparky983 Sparky983 modified the milestones: 0.1, 0.2 Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature API additions proposal To propose features that aren't fully fleshed out (and may be dropped)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant