8000 [FSSDK-10762] Implement UPS request batching for decideForKeys by raju-opti · Pull Request #549 · optimizely/java-sdk · GitHub
[go: up one dir, main page]

Skip to content

[FSSDK-10762] Implement UPS request batching for decideForKeys #549

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

Merged
merged 24 commits into from
Oct 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
up
  • Loading branch information
raju-opti committed Oct 19, 2024
commit 56a041bf11e20b17d205c89e38e2755a6b9e071e
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ public DecisionResponse<Variation> getVariation(@Nonnull Experiment experiment,

if (variation != null) {
if (userProfileTracker != null) {
updateUserProfile(experiment, variation, userProfileTracker.userProfile);
userProfileTracker.profileUpdated = true;
userProfileTracker.updateUserProfile(experiment, variation);
} else {
logger.debug("This decision will not be saved since the UserProfileService is null.");
}
Expand Down Expand Up @@ -233,14 +232,32 @@ private UserProfile getUserProfile(String userId, DecisionReasons reasons) {
return userProfile;
}

static class UserProfileTracker {
class UserProfileTracker {
public UserProfile userProfile;
public boolean profileUpdated;

UserProfileTracker(UserProfile userProfile, boolean profileUpdated) {
this.userProfile = userProfile;
this.profileUpdated = profileUpdated;
}

void updateUserProfile(@Nonnull Experiment experiment,
@Nonnull Variation variation) {

String experimentId = experiment.getId();
String variationId = variation.getId();
Decision decision;
if (userProfile.experimentBucketMap.containsKey(experimentId)) {
decision = userProfile.experimentBucketMap.get(experimentId);
decision.variationId = variationId;
} else {
decision = new Decision(variationId);
}
userProfile.experimentBucketMap.put(experimentId, decision);
profileUpdated = true;
logger.info("Updated variation \"{}\" of experiment \"{}\" for user \"{}\".",
variationId, experimentId, userProfile.userId);
}
}

/**
Expand Down Expand Up @@ -495,31 +512,6 @@ DecisionResponse<Variation> getStoredVariation(@Nonnull Experiment experiment,
}
}

/**
* Save a {@link Variation} of an {@link Experiment} for a user in the {@link UserProfileService}.
*
* @param experiment The experiment the user was buck
* @param variation The Variation to save.
* @param userProfile A {@link UserProfile} instance of the user information.
*/
void updateUserProfile(@Nonnull Experiment experiment,
@Nonnull Variation variation,
@Nonnull UserProfile userProfile) {

String experimentId = experiment.getId();
String variationId = variation.getId();
Decision decision;
if (userProfile.experimentBucketMap.containsKey(experimentId)) {
decision = userProfile.experimentBucketMap.get(experimentId);
decision.variationId = variationId;
} else {
decision = new Decision(variationId);
}
userProfile.experimentBucketMap.put(experimentId, decision);
logger.info("Updated variation \"{}\" of experiment \"{}\" for user \"{}\".",
variationId, experimentId, userProfile.userId);
}

/**
* Save a {@link Variation} of an {@link Experiment} for a user in the {@link UserProfileService}.
*
Expand Down
Loading
0