Skip to content
This repository has been archived by the owner on Sep 13, 2023. It is now read-only.

Global ctx passed into the provider via FeatureProvider #7

Merged
merged 1 commit into from
May 22, 2023

Conversation

fabriziodemaria
Copy link
Member

@fabriziodemaria fabriziodemaria commented May 19, 2023

More context about this change here: open-feature/ofep#41 (comment) (with the related specification now merged in main at the end of this section)

Within a single evaluation, the SDK now propagates the same Context data all the way to the Provider. This ensures that the same Context data is used in the Hooks and in the Provider's Evaluation, preventing possible race conditions caused by the single global Context being read multiple times within the same evaluation

@@ -165,13 +165,14 @@ class OpenFeatureClient(
var details = FlagEvaluationDetails(key, defaultValue)
val provider = openFeatureAPI.getProvider() ?: NoOpProvider()
val mergedHooks: List<Hook<*>> = provider.hooks + options.hooks + hooks + openFeatureAPI.hooks
val context = openFeatureAPI.getEvaluationContext() ?: MutableContext()
Copy link
Member Author

Choose a reason for hiding this comment

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

Sending an optional context to the Provider allows the Provider to be able to distinguish a valid empty context from a missing context, and change the evaluation behaviour accordingly

@fabriziodemaria fabriziodemaria merged commit 9dc869b into main May 22, 2023
@fabriziodemaria fabriziodemaria deleted the ctx-passed-in branch May 22, 2023 09:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants