I9 config snapshot #62
Conversation
We will probably introduce another way to get notified later on.
…to multiple values 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.
…ange feature for separate discussion As agreed in the last EG meeting I gonna split out this feature into a separate ticket (eclipse-archived#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. |
tomas-langer
left a comment
There was a problem hiding this comment.
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 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.
Typo: probably should be "parametrized".
There was a problem hiding this comment.
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.
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.
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.
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.
What if this key is based on multiple variables? Which one is the "resolved one"?
There was a problem hiding this comment.
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.
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.
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.
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.
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.
We need to find a way to test this. Otherwise, how to mandate implementor implement this?
There was a problem hiding this comment.
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 <struberg@apache.org>
|
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). |
Emily-Jiang
left a comment
There was a problem hiding this comment.
TCKs to be added for
- useConverter
- getKey
- getResolvedKey
- getValue(ConfigSnapShot)
| * @return a {@code ConfigValue} to access the given propertyName | ||
| */ | ||
| ConfigValue<String> access(String key); | ||
| ConfigValue<String> access(String propertyName); |
There was a problem hiding this comment.
I would change the method name to getConfigValue instead
There was a problem hiding this comment.
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 | |||
| 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.
Where was TypedResolver defined?
| /** | ||
| * A value holder for TypedResolver values which all got resolved in a guaranteed atomic way. | ||
| * | ||
| * @see Config#snapshotFor(ConfigValue[]) |
| * @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.
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.
No this is intended for when you do not want to use the default converter but a special handling.
| @@ -192,29 +209,24 @@ public interface ConfigValue<T> { | |||
| String getKey(); | |||
There was a problem hiding this comment.
Why does getKey() return a value?
There was a problem hiding this comment.
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.
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.
bulk replaced/fixed all Copyright years to 2018
Signed-off-by: Mark Struberg <struberg@apache.org>
as discussed in the EG meeting Signed-off-by: Mark Struberg <struberg@apache.org>
Emily and Tomas will come up with a better way to test this behaviour
This adresses #9, #8 and #57