Skip to content

Conversation

@oakbani
Copy link
Contributor

@oakbani oakbani commented Oct 21, 2020

Summary

This is the first PR for Decide API.
This PR adds

  • OptimizelyUserContext object
  • create_user_context API in Optimizely Client

Test plan

Added Unit tests.

@oakbani oakbani requested a review from a team as a code owner October 21, 2020 14:35
@oakbani oakbani changed the title Oakbani/decide/user context feat(Decide): Add Optimizely User Context Oct 21, 2020
@oakbani oakbani removed their assignment Oct 21, 2020
@coveralls
Copy link

coveralls commented Oct 21, 2020

Coverage Status

Coverage increased (+0.003%) to 99.589% when pulling c5f138c on oakbani/decide/user-context into b97c41e on master.

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 except for questions about concurrency support.

expected_attributes['browser'] = 'chrome'

expect(user_context_obj.instance_variable_get(:@user_attributes)). to eq(expected_attributes)
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a test - when the caller change its attribute copy after userContext is created, it should not be reflected to userContext?

def initialize(optimizely_client, user_id, user_attributes)
@optimizely_client = optimizely_client
@user_id = user_id
@user_attributes = user_attributes
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this create a copy of the passed user_attributes, so it's not reflected when the client copy is changed later?

end

def set_attribute(attribute_key, attribute_value)
@user_attributes[attribute_key] = attribute_value
Copy link
Contributor

Choose a reason for hiding this comment

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

"set_attribute" can be called concurrently with get-attributes from the userContext. Don't we need to synchronization for attributes read/write?

@oakbani
Copy link
Contributor Author

oakbani commented Nov 11, 2020

Closing in favour of #274

@oakbani oakbani closed this Nov 11, 2020
@oakbani oakbani deleted the oakbani/decide/user-context branch November 11, 2020 13:42
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.

5 participants