Skip to content

refact(forced-decision): Support for decision context added. #326

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 5 commits into from
Nov 2, 2021

Conversation

yasirfolio3
Copy link
Contributor

@yasirfolio3 yasirfolio3 commented Oct 22, 2021

Summary

@msohailhussain msohailhussain marked this pull request as ready for review October 25, 2021 21:36
@msohailhussain msohailhussain requested a review from a team as a code owner October 25, 2021 21:36
Copy link

@jaeopt jaeopt left a comment

Choose a reason for hiding this comment

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

LGTM - I have a few clarification questions. All look good other than them.

if variationKey, ok := f.forcedDecisions[forcedDecision{flagKey: flagKey, ruleKey: ruleKey}]; ok {
return variationKey
if forcedDecision, ok := f.forcedDecisions[context]; ok {
decision.Variation = forcedDecision.Variation
Copy link

Choose a reason for hiding this comment

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

Can we return forcedDecision instead of copying? It'll be independent of extension.

if f.forcedDecisions[decision] != "" {
f.forcedDecisions[decision] = ""
if f.forcedDecisions[context].Variation != "" {
f.forcedDecisions[context] = OptimizelyForcedDecision{}
Copy link

Choose a reason for hiding this comment

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

wondering if this is better than remove the key.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Directly modifying the variation throws this error cannot assign to struct field f.forcedDecisions[context].Variation in map. I have committed a change to avoid creating a new object here.

if len(f.forcedDecisions) == 0 {
return ""
return decision
Copy link

Choose a reason for hiding this comment

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

Wondering if this is idiomatic to return empty struct (instead of nil, or paired with err)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Returning an error is the natural way to do it, will make the change in the next commit.

@yasirfolio3 yasirfolio3 removed their assignment Oct 27, 2021
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

@msohailhussain msohailhussain merged commit 82644c6 into master Nov 2, 2021
@msohailhussain msohailhussain deleted the yasir/decision-context branch November 2, 2021 21:51
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.

3 participants