-
Notifications
You must be signed in to change notification settings - Fork 19
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
Conversation
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.
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 |
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.
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{} |
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.
wondering if this is better than remove the key.
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.
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 |
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.
Wondering if this is idiomatic to return empty struct (instead of nil, or paired with err)
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.
Returning an error is the natural way to do it, will make the change in the next commit.
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.
lgtm
Summary