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

Refactor on #388 PR #392

Merged
merged 9 commits into from
Feb 8, 2019
Merged

Refactor on #388 PR #392

merged 9 commits into from
Feb 8, 2019

Conversation

Emily-Jiang
Copy link
Member

No description provided.

struberg and others added 5 commits September 4, 2018 19:58
…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 <emijiang@uk.ibm.com>
.addAsServiceProvider(ConfigSource.class, ConfigurableConfigSource.class)
.as(JavaArchive.class);

AbstractTest.addFile(testJar, "META-INF/javaconfig.properties");
Copy link
Contributor

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

Copy link
Member Author

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
Copy link
Contributor

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

Copy link
Member Author

@Emily-Jiang Emily-Jiang Dec 17, 2018

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?

Copy link
Contributor

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 <emijiang@uk.ibm.com>

/**
* 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.
Copy link
Contributor

@dmlloyd dmlloyd Dec 17, 2018

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.

Copy link
Contributor

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

Copy link
Member Author

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 <emijiang@uk.ibm.com>
* @param timeUnit the ChronoUnit for the value
* @return This builder
*/
ConfigAccessorBuilder<T> cacheFor(long value, ChronoUnit timeUnit);
Copy link
Contributor

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

Copy link
Member Author

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) {
Copy link
Contributor

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".

Copy link
Member Author

@Emily-Jiang Emily-Jiang Jan 18, 2019

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;

Copy link
Contributor

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

Copy link
Member Author

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.
Copy link
Member Author

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);
Copy link
Member Author

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);
Copy link
Member Author

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;

Copy link
Member Author

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) {
Copy link
Member Author

@Emily-Jiang Emily-Jiang Jan 18, 2019

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 <emijiang@uk.ibm.com>
@Emily-Jiang
Copy link
Member Author

@jmesnil @OndroMih @tevans78 I have done the changes based on our discussion last week. please review the changes again. I would like to merge them before tomorrow's meeting, so that we can discuss how best to do prefix or suffix on property names.

Signed-off-by: Emily Jiang <emijiang@uk.ibm.com>
Copy link
Contributor

@jmesnil jmesnil left a 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)

@Emily-Jiang Emily-Jiang merged commit e4b258b into master Feb 8, 2019
@OndroMih OndroMih mentioned this pull request Feb 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants