-
Notifications
You must be signed in to change notification settings - Fork 32
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: Added ODPSegmentManager #484
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.
Looks good! A couple of suggestions.
} | ||
|
||
public void setApiKey(String apiKey) { | ||
this.apiKey = apiKey; |
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.
thread-safety for all props?
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.
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()); |
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 add filtering for cases when odpConfig.getAllSegments() is empty?
We should not send this request to the ODP server.
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.
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()); |
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.
what if odpConfig is not ready (apiKey and apiHost null)?
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.
Added a check and a unit test.
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.
All changes look good! One more suggestion to change error log message format.
@@ -66,6 +66,16 @@ public List<String> getQualifiedSegments(ODPUserKey userKey, String userValue) { | |||
} | |||
|
|||
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"); |
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 change all error messages to the standard format (see TDD)?
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.
Done
ODPSegmentManager segmentManager = new ODPSegmentManager(odpConfig, mockApiManager, mockCache); | ||
List<String> segments = segmentManager.getQualifiedSegments(ODPUserKey.FS_USER_ID, "testId"); | ||
|
||
// Cache lookup called with correct 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.
This and next comments misleading.
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.
Removed the comments
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.
One more fix please :)
@@ -67,7 +67,7 @@ public List<String> getQualifiedSegments(ODPUserKey userKey, String userValue) { | |||
|
|||
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."); |
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.
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.
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.
Done!
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
Added an ODPSegmentManager which provides functionality to fetch segments from ODP server and cache and re-use them.
Test plan
JIRA
OASIS-8383