Skip to content

Conversation

@zashraf1985
Copy link
Contributor

Summary

Added an ODPSegmentManager which provides functionality to fetch segments from ODP server and cache and re-use them.

Test plan

  • Manually tested thoroughly
  • Added new unit tests
  • Existing unit tests pass
  • All Full stack compatibility suite tests pass

JIRA

OASIS-8383

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 couple of suggestions.

}

public void setApiKey(String apiKey) {
this.apiKey = apiKey;
Copy link
Contributor

Choose a reason for hiding this comment

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

thread-safety for all props?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made all getters and setters synchronized

logger.debug("ODP Cache Miss. Making a call to ODP Server");

ResponseJsonParser parser = ResponseJsonParserFactory.getParser();
String qualifiedSegmentsResponse = apiManager.fetchQualifiedSegments(odpConfig.getApiKey(), odpConfig.getApiHost() + SEGMENT_URL_PATH, userKey.getKeyString(), userValue, odpConfig.getAllSegments());
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 filtering for cases when odpConfig.getAllSegments() is empty?
We should not send this request to the ODP server.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a check and a unit test.

logger.debug("ODP Cache Miss. Making a call to ODP Server");

ResponseJsonParser parser = ResponseJsonParserFactory.getParser();
String qualifiedSegmentsResponse = apiManager.fetchQualifiedSegments(odpConfig.getApiKey(), odpConfig.getApiHost() + SEGMENT_URL_PATH, userKey.getKeyString(), userValue, odpConfig.getAllSegments());
Copy link
Contributor

Choose a reason for hiding this comment

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

what if odpConfig is not ready (apiKey and apiHost null)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a check and a unit test.

@zashraf1985 zashraf1985 removed their assignment Aug 17, 2022
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.

All changes look good! One more suggestion to change error log message format.


public List<String> getQualifiedSegments(ODPUserKey userKey, String userValue, List<ODPSegmentOption> options) {
if (!odpConfig.isReady()) {
logger.warn("ODP Config not ready. apiHost and/or apiKey null. Returning Empty list");
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 change all error messages to the standard format (see TDD)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

ODPSegmentManager segmentManager = new ODPSegmentManager(odpConfig, mockApiManager, mockCache);
List<String> segments = segmentManager.getQualifiedSegments(ODPUserKey.FS_USER_ID, "testId");

// Cache lookup called with correct key
Copy link
Contributor

Choose a reason for hiding this comment

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

This and next comments misleading.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the comments

@zashraf1985 zashraf1985 removed their assignment Aug 17, 2022
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.

One more fix please :)

public List<String> getQualifiedSegments(ODPUserKey userKey, String userValue, List<ODPSegmentOption> options) {
if (!odpConfig.isReady()) {
logger.warn("ODP Config not ready. apiHost and/or apiKey null. Returning Empty list");
logger.error("ODP is not enabled.");
Copy link
Contributor

Choose a reason for hiding this comment

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

I mean all segments error should come with "Audience segments fetch failed ()". So in this case, "Audience segments fetch failed (ODP is not enabled)". These common messages will be used for all SDKs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@zashraf1985 zashraf1985 removed their assignment Aug 17, 2022
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

@zashraf1985 zashraf1985 merged commit 1cf2d72 into master Aug 18, 2022
@zashraf1985 zashraf1985 deleted the zeeshan/ats-segment-manager branch August 18, 2022 00:08
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