-
Notifications
You must be signed in to change notification settings - Fork 22
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
I9 config snapshot #62
Conversation
We will probably introduce another way to get notified later on.
This code got originally developed on 2018-04-04 in Apache DeltaSpike by Mark Struberg, Manfred Huber, Alex Falb, Gerhard Petracek and Romain Manni-Bucau based on the problem analysis discussions between Mark Struberg and Tomas Langer (tomas-langer) who also did reviews and gave important feedback.
…eparate discussion As agreed in the last EG meeting I gonna split out this feature into a separate ticket (eclipse#63).
Using the same attributes in different TCK tests but with different values leads to random behaviour of the whole TCK suite.
Hi! I've removed the onValueChange callback as discussed in our last EG meeting. |
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.
There are a few things that should be fixed before merging.
* Returns the actual key which led to successful resolution and corresponds to the resolved value. This applies | ||
* only when {@link #withLookupChain(String...)} is used. | ||
* Returns the actual key which led to successful resolution and corresponds to the resolved value. | ||
* This is mostly useful when {@link #withLookupChain(String...)} or {@link #evaluateVariables(boolean)} is used. | ||
* Otherwise the resolved key should always be equal to the original key. | ||
* This method is provided for cases, when arameterized resolution is |
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.
Typo: probably should be "parametrized".
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.
Actually evaluateVariables does not have any impact at all the more I think about it.
evaluateVariable works on the value. It is a post processing of the value. But it doesn't affect the key at all. Gonna remove it.
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.
Just wondered whether we should remove getResolvedKey at all?
It only gives you the value from the last 'successful' resolve. And if this happens in parallel rather quickly you might end up with glitches from another thread.
Of course this will only happen if the underlying config changes, otherwise it will be idempotent anyway.
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.
Yes, the usability is questionable - why would I need this information in my business logic?
Though there may be some troubleshooting use cases (e.g. debugging this information).
I don't have a strong opinion on this one, so choose ;)
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.
Indeed, would be clever to log it out in case of onChange - If only we would not just have ditched that ;)
* Returns the actual key which led to successful resolution and corresponds to the resolved value. This applies | ||
* only when {@link #withLookupChain(String...)} is used. | ||
* Returns the actual key which led to successful resolution and corresponds to the resolved value. | ||
* This is mostly useful when {@link #withLookupChain(String...)} or {@link #evaluateVariables(boolean)} 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.
What if this key is based on multiple variables? Which one is the "resolved one"?
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.
The last effective String.
So if you have cfg.access("myconfigkey").withLookupChain("${app.projectstage}")
and app.projectstage resolves to 'Prodution' you might end up with 'myconfigkey.Production'
int i2 = vals.get(DynamicChangeConfigSource.TEST_ATTRIBUTE); | ||
assertTrue(i2 > i1); | ||
public void testValueInvalidationOnConfigChange() throws Exception { | ||
ConfigValue<Integer> valCfg = config.access(DynamicChangeConfigSource.TEST_ATTRIBUTE) |
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 considered this to be optional approach by the implementor. This behavior should not be tested - the implementation may decide not to refresh the value until the cache for is expired.
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.
Well, the intention is to define that it must expire the cache if the Config gets notified about a change by the ConfigSource. Do you really think we should not mandate this?
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.
Yes I think so. This does not stand in the way of portability. We can mention that the implementation should refresh the value, though I still don't see this as a must.
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.
But not defining this as mandatory feature renders ConfigSource#setOnAttributeChange useless on implementations not supporting it.
So I'd rather tighten it instead of removing.
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.
We need to find a way to test this. Otherwise, how to mandate implementor implement this?
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.
There should be a test for it already. It sets a cacheFor to 15 minutes, then loads the values. Then the ConfigSource changes a value via the TCK test and fires the attributeChanged to the Config. And then the test reads the value again and verifies that the new value is picked up immediately.
Signed-off-by: Mark Struberg <[email protected]>
Oki so in summary? Looks fine @tomas-langer? In which case I suggest we apply it now and refine it all together. |
LGTM, I would go through the must/should decision during our meeting next week (as this is to be decided in the spec - and TCK can be changed accordingly if we decide against your approach). |
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.
TCKs to be added for
- useConverter
- getKey
- getResolvedKey
- getValue(ConfigSnapShot)
*/ | ||
ConfigValue<String> access(String key); | ||
ConfigValue<String> access(String propertyName); |
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 would change the method name to getConfigValue
instead
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'd rather not do that. Then we'd have getValue and getConfigValue. That would confuse users I fear.
@@ -0,0 +1,42 @@ | |||
/* | |||
******************************************************************************* | |||
* Copyright (c) 2011-2017 Contributors to the Eclipse Foundation and others |
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 be 2011-2018
package javax.config; | ||
|
||
/** | ||
* A value holder for TypedResolver values which all got resolved in a guaranteed atomic way. |
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.
Where was TypedResolver defined?
/** | ||
* A value holder for TypedResolver values which all got resolved in a guaranteed atomic way. | ||
* | ||
* @see Config#snapshotFor(ConfigValue[]) |
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.
It is varargs
* @return This builder as a typed ConfigValue | ||
*/ | ||
<N> ConfigValue<N> useConverter(Converter<N> converter); | ||
ConfigValue<T> useConverter(Converter<T> converter); |
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 should this converter here? Is this converter not loaded via service loader pattern? What is the use case here?
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.
No this is intended for when you do not want to use the default converter but a special handling.
@@ -192,29 +209,24 @@ | |||
String getKey(); |
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 does getKey() return a 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.
This is the name of the oridingal config property name. We might probably rename it.
int i2 = vals.get(DynamicChangeConfigSource.TEST_ATTRIBUTE); | ||
assertTrue(i2 > i1); | ||
public void testValueInvalidationOnConfigChange() throws Exception { | ||
ConfigValue<Integer> valCfg = config.access(DynamicChangeConfigSource.TEST_ATTRIBUTE) |
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.
We need to find a way to test this. Otherwise, how to mandate implementor implement this?
@@ -0,0 +1,79 @@ | |||
/* | |||
* Copyright (c) 2016-2017 Contributors to the Eclipse Foundation |
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.
2016-2018
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.
bulk replaced/fixed all Copyright years to 2018
Signed-off-by: Mark Struberg <[email protected]>
as discussed in the EG meeting Signed-off-by: Mark Struberg <[email protected]>
Emily and Tomas will come up with a better way to test this behaviour
This adresses #9, #8 and #57