Skip to content

feat: added notification support for json variable #253

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

Merged
merged 2 commits into from
Apr 23, 2020

Conversation

pawels-optimizely
Copy link
Contributor

Summary

  • properly handling json variable in the notification listener

@pawels-optimizely pawels-optimizely requested a review from a team as a code owner April 21, 2020 19:31
@pawels-optimizely pawels-optimizely self-assigned this Apr 21, 2020
@pawels-optimizely pawels-optimizely removed their assignment Apr 21, 2020
Copy link
Contributor

@msohailhussain msohailhussain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Contributor

@mikeproeng37 mikeproeng37 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a comment, will leave for @mjc1283 to approve

@@ -113,6 +114,9 @@ func (s CompositeService) GetFeatureDecision(featureDecisionContext FeatureDecis
convertedValue, e = strconv.ParseFloat(variableValue, 64)
case entities.Boolean:
convertedValue, e = strconv.ParseBool(variableValue)
case entities.JSON:
convertedValue = map[string]string{}
e = json.Unmarshal([]byte(variableValue), &convertedValue)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering now, if we should lazy unmarshal and cache the map in the variable itself the first time it is ever accessed and from there on we can just refer to that value. Seems like this could potentially be a costly operation to repeat

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point

@@ -113,6 +114,9 @@ func (s CompositeService) GetFeatureDecision(featureDecisionContext FeatureDecis
convertedValue, e = strconv.ParseFloat(variableValue, 64)
case entities.Boolean:
convertedValue, e = strconv.ParseBool(variableValue)
case entities.JSON:
convertedValue = map[string]string{}
e = json.Unmarshal([]byte(variableValue), &convertedValue)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point

@@ -113,6 +114,9 @@ func (s CompositeService) GetFeatureDecision(featureDecisionContext FeatureDecis
convertedValue, e = strconv.ParseFloat(variableValue, 64)
case entities.Boolean:
convertedValue, e = strconv.ParseBool(variableValue)
case entities.JSON:
convertedValue = map[string]string{}
e = json.Unmarshal([]byte(variableValue), &convertedValue)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we pass the OptimizelyJSON object to the notification, rather than the JSON string? And apply memoization to creating the OptimizelyJSON as @mikeng13 suggested?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

memoization is already done on OptimizelyJSON, the thing is that GetFeatureDecision does not know anything about OptimizelyJSON. This whole notification logic will need to be restructured.

Copy link
Contributor

@mjc1283 mjc1283 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes for the memoization - @pawels-optimizely let me know if that's reasonable.

Copy link
Contributor

@mjc1283 mjc1283 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed with @pawels-optimizely . We think the memoization should be done, but it requires more investigation to be done separately.

@pawels-optimizely pawels-optimizely merged commit 6e3fd0f into master Apr 23, 2020
@pawels-optimizely pawels-optimizely deleted the pawel/notification_for_json branch April 23, 2020 04:03
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.

4 participants