-
Notifications
You must be signed in to change notification settings - Fork 116
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
Refactor on #388 PR #392
Refactor on #388 PR #392
Conversation
…ojects. All ALv2, authors noted in source and NOTICE files.
All changes originally by me, except 1 smallish fixes by Tomas Langer.
This also includes a fix to avoid OS specific hacks (envconfig.* properties)
Signed-off-by: Emily Jiang <[email protected]>
.addAsServiceProvider(ConfigSource.class, ConfigurableConfigSource.class) | ||
.as(JavaArchive.class); | ||
|
||
AbstractTest.addFile(testJar, "META-INF/javaconfig.properties"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Emily-Jiang please change it to META-INF/microprofile-config.properties
to make the test deploy properly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed. thanks @jmesnil
Assert.assertEquals(config.access("tck.config.variable.secondEndpoint", String.class).build().getValue(), | ||
"http://some.host.name/endpointTwo"); | ||
|
||
// variables in Config.getValue and getOptionalValue do not get evaluated otoh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are they not evaluated? for backwards compatibility?
Does it support nested variable replacement? e.g. ${foo.${bar}}
Does it support default value? e.g. ${foo:123}
-> returns 123
if the prop foo
is not found
Does it support escaping? (so that the string ${
can appear without being an expression
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are not evaluated for backward compatibility. The variables were evaluated only via configaccess object.
${foo.${bar}} should be evaluated recursively.
At the moment, it does not support default value if a particular variable does not exist. I suggest For the case of ${foo}, if foo
does not exist, we could either fail with exception or not to evaluate the variable.
Good point of the escaping aspect, we have not talked about this. I think it is a good idea to introduce escaping... how about ${... escape a escape character will be \${-> ${, ${ will be still escaped
@struberg what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I'm an outsider here but just wanted to comment that it would be nice if there was a way to be able to use variable expansion directly on the Config
interface. Couldn't this be something set on org.eclipse.microprofile.config.spi.ConfigBuilder
?
… - address comments Signed-off-by: Emily Jiang <[email protected]>
|
||
/** | ||
* Returns the actual key which led to successful resolution and corresponds to the resolved value. | ||
* This is useful when {@link ConfigAccessorBuilder#addLookupSuffix(String)} is used. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unconstrained suffixes are not a good idea as they add a grammatical ambiguity that can lead to unexpected behavior, especially with large or complex configurations. How about adding some constraining rules instead? E.g. a syntax that is only valid for this case? Also, I'm not sure the suffix is the right affix to use; is there some established practice in this area? I know Play 1 used prefixes, and used %
to disambiguate the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reference, David is talking about https://www.playframework.com/documentation/1.5.x/ids
However, it seems that Play 2 has dropped out this feature and uses instead a simpler devSettings
:
https://www.playframework.com/documentation/2.6.x/ConfigFile#Extra-devSettings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll remove this method for now and raise a separate issue for further discussion.
… - address comments Signed-off-by: Emily Jiang <[email protected]>
* @param timeUnit the ChronoUnit for the value | ||
* @return This builder | ||
*/ | ||
ConfigAccessorBuilder<T> cacheFor(long value, ChronoUnit timeUnit); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should use Duration rather than a long and a ChronoUnit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will update to Duration.
* @return ChangeSupport informing the {@link org.eclipse.microprofile.config.Config} implementation about support for changes by this source | ||
* @see ChangeSupport | ||
*/ | ||
default ChangeSupport onAttributeChange(Consumer<Set<String>> callback) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since a ConfigSource can be shared between multiple Config instances, this method should be an "add" and there should also be a corresponding "remove".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add two more methods:
RegisterChangeListener
ReleaseChangeListener
@@ -135,4 +137,25 @@ | |||
*/ | |||
@Nonbinding | |||
String defaultValue() default UNCONFIGURED_VALUE; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why this diff isn't flagging it up as a change but there should be a typo in the value of UNCONFIGURED_VALUE, an extra 'd'...
String UNCONFIGURED_VALUE="org.eclipse.microprofile.config.configproperty.unconfigureddvalue";
This was previously removed but then re-instated by PR #391
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert back to the master branch.
|
||
/** | ||
* Returns the actual key which led to successful resolution and corresponds to the resolved value. | ||
* This is useful when {@link ConfigAccessorBuilder#addLookupSuffix(String)} is used. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll remove this method for now and raise a separate issue for further discussion.
* @param timeUnit the ChronoUnit for the value | ||
* @return This builder | ||
*/ | ||
ConfigAccessorBuilder<T> cacheFor(long value, ChronoUnit timeUnit); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will update to Duration.
* @param suffixValue fixed String to be used as suffix | ||
* @return This builder | ||
*/ | ||
ConfigAccessorBuilder<T> addLookupSuffix(String suffixValue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will remove this method for now.
@@ -135,4 +137,25 @@ | |||
*/ | |||
@Nonbinding | |||
String defaultValue() default UNCONFIGURED_VALUE; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert back to the master branch.
* @return ChangeSupport informing the {@link org.eclipse.microprofile.config.Config} implementation about support for changes by this source | ||
* @see ChangeSupport | ||
*/ | ||
default ChangeSupport onAttributeChange(Consumer<Set<String>> callback) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add two more methods:
RegisterChangeListener
ReleaseChangeListener
Signed-off-by: Emily Jiang <[email protected]>
Signed-off-by: Emily Jiang <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok with merging the PR as it stands (with further PRs to improve it)
No description provided.