Skip to content

[FSSDK-11143] update: Implement CMAB Client #579

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

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

FarhanAnjum-opti
Copy link
Contributor

Summary

  • Implemented DefaultCmabClient, a client for fetching CMAB (Contextual Multi-Armed Bandit) decisions.

  • Supports configurable retries with exponential backoff through CmabRetryConfig.

  • Handles error scenarios such as network failures, non-2xx responses, invalid JSON, and malformed responses.

  • Logs relevant error and retry information using the Optimizely logger.

Test plan

  • Created unit tests for checking various scenarios.

Issues

Copy link
Contributor

@muzahidul-opti muzahidul-opti 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 to me. Added a couple of comments.

* @param cmabUuid The CMAB UUID
* @return CompletableFuture containing the variation ID as a String
*/
CompletableFuture<String> fetchDecision(String ruleId, String userId, Map<String, Object> attributes, String cmabUuid);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can we rename it as cmabUUID?

private final int maxRetries;
private final long backoffBaseMs;
private final double backoffMultiplier;

Copy link
Contributor

Choose a reason for hiding this comment

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

I think there should a maxTimeout.

if (attemptNumber < 0) {
return 0;
}
return (long) (backoffBaseMs * Math.pow(backoffMultiplier, attemptNumber));
Copy link
Contributor

Choose a reason for hiding this comment

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

This logic should be updated with maxTimeOut

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.

2 participants