Skip to content
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

feat(decide): clone user-context before calling optimizely decide #256

Merged
merged 5 commits into from
Jan 19, 2021

Conversation

mnoman09
Copy link
Contributor

Clone the current user-context and pass it to optimizely.decide(), decide all and in decideForKeys

  • user context can be changed while processing the decide request.
  • with this fix, decide can return the copy of the original user-context as a part of the decision

Copy link
Contributor

@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.

Looks good. A change suggested.

@@ -46,6 +46,8 @@ public OptimizelyUserContext(Optimizely optimizely, string userId, UserAttribute
UserId = userId;
}

private OptimizelyUserContext Clone() => new OptimizelyUserContext(Optimizely, UserId, Attributes, ErrorHandler, Logger);
Copy link
Contributor

Choose a reason for hiding this comment

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

change "Attributes" to "getAttributes()", which should be mutex protected while copying.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also rename it to Copy.

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. please address jae's comments.

@mnoman09 mnoman09 removed their assignment Jan 13, 2021
@mnoman09 mnoman09 requested a review from jaeopt January 13, 2021 08:52
Copy link
Contributor

@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

@jaeopt jaeopt merged commit 46aff7f into master Jan 19, 2021
@jaeopt jaeopt deleted the mnoman/cloneUserContext branch January 19, 2021 22:09
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