Skip to content

Commit 1269180

Browse files
add: implement fetchDecision method in DefaultCmabService for decision retrieval
1 parent 3ab4324 commit 1269180

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

core-api/src/main/java/com/optimizely/ab/cmab/service/DefaultCmabService.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ public CmabDecision getDecision(ProjectConfig projectConfig, OptimizelyUserConte
3333
return null;
3434
}
3535

36+
private CmabDecision fetchDecision(String ruleId, String userId, Map<String, Object> attributes) {
37+
String cmabUuid = java.util.UUID.randomUUID().toString();
38+
String variationId = cmabClient.fetchDecision(ruleId, userId, attributes, cmabUuid);
39+
return new CmabDecision(variationId, cmabUuid);
40+
}
41+
3642
private Map<String, Object> filterAttributes(ProjectConfig projectConfig, OptimizelyUserContext userContext, String ruleId) {
3743
Map<String, Object> userAttributes = userContext.getAttributes();
3844
Map<String, Object> filteredAttributes = new HashMap<>();
@@ -90,9 +96,6 @@ private String getCacheKey(String userId, String ruleId) {
9096
return userId.length() + "-" + userId + "-" + ruleId;
9197
}
9298

93-
/**
94-
* Hash attributes using MD5
95-
*/
9699
private String hashAttributes(Map<String, Object> attributes) {
97100
try {
98101
// Sort attributes to ensure consistent hashing

0 commit comments

Comments
 (0)