Related to #454
MergeTransactionContext does a couple of things:
- Call
TransactionContext to extract an EvaluationContext from the given context.Context
- Merge the given EvaluationContext with the one extracted from the step above
- Return a new context.Context that contains the merged EvaluationContext from the step above.
I propose that we deprecate this function. I would argue that it's doing too much and naming it more appropriately is not possible without creating a really long name.
Before we attempt to fill the gap, I'd like to establish the usefulness of this function, given that it's not defined in the spec (https://openfeature.dev/specification/sections/evaluation-context). Here I am specifically referring to the ability of merging evaluation contexts, whether directly via a function that takes multiple evaluation contexts, or indirectly by merging the "transaction context" in the "transaction context propagator" with a different evaluation context. We need to determine whether similar behaviour exists in the other languages. If so, we should consider updating the spec if we want this functionality implemented consistently across all languages.
Either way, there are two ways to implement this functionality, if we decide that we need this:
- Export (and rename) the existing
mergeContexts function to allow users to merge evaluation contexts.
- Merge evaluation contexts indirectly as described in the paragraph above (essentially what MergeTransactionContext does), but rename the function. We'll need to come up with a good name in this case.
|
func mergeContexts(evaluationContexts ...EvaluationContext) EvaluationContext { |
I personally prefer the first option, which is a more more modular approach. I think that the existing MergeTransactionContext function does too many things.
Related to #454
MergeTransactionContext does a couple of things:
TransactionContextto extract an EvaluationContext from the given context.ContextI propose that we deprecate this function. I would argue that it's doing too much and naming it more appropriately is not possible without creating a really long name.
Before we attempt to fill the gap, I'd like to establish the usefulness of this function, given that it's not defined in the spec (https://openfeature.dev/specification/sections/evaluation-context). Here I am specifically referring to the ability of merging evaluation contexts, whether directly via a function that takes multiple evaluation contexts, or indirectly by merging the "transaction context" in the "transaction context propagator" with a different evaluation context. We need to determine whether similar behaviour exists in the other languages. If so, we should consider updating the spec if we want this functionality implemented consistently across all languages.
Either way, there are two ways to implement this functionality, if we decide that we need this:
mergeContextsfunction to allow users to merge evaluation contexts.go-sdk/openfeature/client.go
Line 836 in 4b3d6d9
I personally prefer the first option, which is a more more modular approach. I think that the existing MergeTransactionContext function does too many things.