[FFL-1579] Add callback support to setEvaluationContext method#3056
Conversation
|
🎯 Code Coverage 🔗 Commit SHA: 1088bcd | Docs | Datadog PR Page | Was this helpful? Give us feedback! |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3056 +/- ##
===========================================
+ Coverage 71.24% 71.28% +0.04%
===========================================
Files 866 867 +1
Lines 31730 31729 -1
Branches 5360 5362 +2
===========================================
+ Hits 22604 22615 +11
+ Misses 7602 7591 -11
+ Partials 1524 1523 -1
🚀 New features to boost your workflow:
|
0xnm
left a comment
There was a problem hiding this comment.
Some minor comments/suggestions only.
The only major comment is to avoid passing generic Throwable and switch to the more precise exception.
| { NETWORK_REQUEST_FAILED_MESSAGE } | ||
| ) | ||
|
|
||
| val throwable = Throwable(NETWORK_REQUEST_FAILED_MESSAGE) |
There was a problem hiding this comment.
minor: it is better to avoid creating generic Throwable. Probably here it is better to create some NetworkCallFailedException: RuntimeException and pass it instead.
yugisu-flux
left a comment
There was a problem hiding this comment.
Looks great, thanks for adding this! (+1 to Nikita's feedback)
Co-authored-by: Nikita Ogorodnikov <[email protected]>
typotter
left a comment
There was a problem hiding this comment.
Thanks Nikita. PTAL
| { NETWORK_REQUEST_FAILED_MESSAGE } | ||
| ) | ||
|
|
||
| val throwable = Throwable(NETWORK_REQUEST_FAILED_MESSAGE) |
0xnm
left a comment
There was a problem hiding this comment.
lgtm, but I think that exception class can be made internal, see my comment below.
| * | ||
| * @param message A descriptive message about the network failure | ||
| */ | ||
| class NetworkRequestFailedException(message: String) : RuntimeException(message) |
There was a problem hiding this comment.
minor: if there is no intention to expose the type to the user to do some matching, we can simply make it internal. And probably we should do that, because this is the only exception type we can propagate so far, so there is no alternatives to match against in the user code.
typotter
left a comment
There was a problem hiding this comment.
Thanks Nikita. Just need a final stamp for the last change.
|
/merge |
|
View all feedbacks in Devflow UI.
This pull request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings.
The expected merge time in
Tests failed on this commit 6ca8cba: What to do next?
|
13f51d7 to
96404fa
Compare
typotter
left a comment
There was a problem hiding this comment.
Sorry Nikita. Missed moving the exception to the internal.net package
Please stamp again.
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
|
What does this PR do?
Adds an optional callback parameter to the
FlagsClient.setEvaluationContext()method to enable applications - and Openfeature SDK modules built ontop offlagsto block and wait for the completion of the async network request triggered by this method.Motivation
The current
setEvaluationContext()method is fire-and-forget, making it difficult for applications to:This change adds a standard callback interface (
EvaluationContextCallback) that follows existing SDK patterns (e.g.,DataStoreWriteCallback) to notify callers of success or failure.Implementation Details
New Public API:
EvaluationContextCallbackinterface withonSuccess()andonFailure(error: Throwable)methodsFlagsClient.setEvaluationContext()to accept optional callback parameterCallback Semantics:
onSuccess()- Called when state transitions toFlagsClientState.Ready(network fetch succeeded)onFailure(error)- Called when state transitions toFlagsClientState.StaleorFlagsClientState.Error(network request failed)onSuccess()for graceful degradation consistencyThread Safety:
executeSafe()exception handlingAdditional Notes
Design Decisions:
nullReview checklist (to be filled by reviewers)