-
Notifications
You must be signed in to change notification settings - Fork 32
[FSSDK-11172] feat: update decision service to handle CMAB #602
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
base: master
Are you sure you want to change the base?
Conversation
# Conflicts: # OptimizelySwiftSDK.xcodeproj/project.pbxproj # Sources/CMAB/CmabClient.swift # Tests/OptimizelyTests-Common/CMABClientTests.swift
# Conflicts: # Sources/CMAB/CmabService.swift # Tests/OptimizelyTests-Common/CmabServiceTests.swift
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.
It looks good. I have a suggestion to clean up .opType passing down.
Let's discuss about the option.
|
||
extension DefaultCmabService { | ||
static func createDefault() -> DefaultCmabService { | ||
let DEFAULT_CMAB_CACHE_TIMEOUT = 30 * 60 * 1000 // 30 minutes in milliseconds |
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 like this timeout is too large - is this consistent for all SDKs? @raju-opti
if !mutexAllowed { | ||
return DecisionResponse(result: nil, reasons: reasons) | ||
} | ||
|
||
if !mutexAllowed { return DecisionResponse(result: nil, reasons: reasons) } |
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.
clean up redundant?
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.
Yes, reuse the mutex logic.
|
||
var cmabDecision: CmabDecision? | ||
/// Fetch CMAB decision | ||
let response = cmabService.getDecision(config: config, userContext: user, ruleId: experiment.id, options: options ?? []) |
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 is blocking call. Is it ok?
return | ||
} | ||
|
||
let decision = self.decide(user: user, keys: config.featureFlagKeys, options: options, opType: .async, ignoreDefaultOptions: false) |
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.
why "ignoreDefaultOptions=false" here? Not consistent with sync version above?
guard opType == .async else { | ||
let info = LogMessage.cmabNotSupportedInSyncMode | ||
logger.w(info) | ||
reasons.addInfo(info) | ||
return DecisionResponse(result: nil, reasons: reasons) | ||
} |
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 check if running thread, and reject if main thread?
CMAB can be called in sync decide inside of background thread?
Summary
Test plan
Issues