Closed Kavindu-Dodan closed 3 weeks ago
The addition of the TargetingKey
property has presented some problems for the LaunchDarkly provider. We had supported using attributes with the name "key" (convenient coming from an LD context) as well as "targetingKey". The TargetingKey
not being in the map just meant we basically were unaware of it.
I wonder if we should have just made it short-hand for "targetingKey" as a member of the underlying structure. If we just export it, then we have to use some kind of name that will shadow whatever we pick. (Likely "targetingKey").
Instead we could adjust the general Set
method to have restrictions on "targetingKey". We do something similar in LD contexts where if you call the set function with a built-in attribute we do our best, and then log if we cannot handle it.
Similar situation: https://github.com/launchdarkly/dotnet-sdk-common/blob/d248d74b29fb0d1e27771c5810b8277fd256e266/src/LaunchDarkly.CommonSdk/ContextBuilder.cs#L272
@kinyoklion I think I understand what you're suggesting, but I want to be sure... Are you suggesting that you think the targeting key setter/getter should just retrieve a "special" property from the map (probably targetingKey
?
I think that's fine, if so. I think the real problem is just that people will expect the AsDictionary()
and GetEnumerator()
to convey a targeting key, somehow if it's set.
We're close to being about to release a 2.0, so I'm reviewing some of these open issues.
@toddbaert Yeah, I am suggesting that the key of "targetingKey" and the setter/getter for targetingKey should operate on the same value.
Which either requires a specially interacted with field or a special entry in the map with specialized logic for the set/get generic mechanisms.
Set("targetingKey", "potato"); TargetingKey = "potato";
var targetingKey = Get("targetingKey"); var targetingKey = TargetingKey
Should all basically be setting/getting the same field, and that field should also be in the dictionary.
I'm fine with that. I'll add it to the description, and try to get to it myself if nobody else does first.
I'm starting on this.
Requirements
Similar to the Java SDK [1], Dotnet SDK
EvaluationContext
should include targetingKey with bulk exporters.Currently
EvaluationContext
exposesAsDictionary()
[2] as well asGetEnumerator()
[3], but they do not include thetargetingKey
, which is stored in a dedicated field.AC
Include the targetingKey in bulk exporters and refactor of the property to match with this change
[1] - https://github.com/open-feature/java-sdk/issues/801 [2] - https://github.com/open-feature/dotnet-sdk/blob/v1.4.1/src/OpenFeature/Model/EvaluationContext.cs#L76 [3] - https://github.com/open-feature/dotnet-sdk/blob/v1.4.1/src/OpenFeature/Model/EvaluationContext.cs#L90