open-feature / spec

OpenFeature specification
https://openfeature.dev
Apache License 2.0
667 stars 35 forks source link

Add requirements/clarification specifying context can be provided globally, at client creation, and flag evaluation #75

Closed toddbaert closed 2 years ago

toddbaert commented 2 years ago

Similarly to hooks, I think we want to allow setting global, client, and evaluation context. We will also need to describe how they are merged. This should be a fairly minor change to the spec, unless we want to get fancy with how to merge the contexts. We can mention it in the Evaluation Context spec, and link to the new requirements in the Flag Evaluation spec.

I'm proposing a simple merge where the invocation context overwrites properties in the client context, which overwrites properties in the global context:

    // merge global, client, and evaluation context
    const mergedContext = {
      ...globalContext,
      ...clientContext,
      ...invocationContext,
    };

Another option would be to define a merge function so that app-authors could have full control of how the merge works, perhaps with the above as a default.

justinabrahms commented 2 years ago

I dislike a custom merge function but we can add one later if we need to. This works for me.

Before Hook generated context will sit between invocation and client context.

toddbaert commented 2 years ago

Before Hook generated context will sit between invocation and client context.

I think that's a good point, and I agree with that precedence.

beeme1mr commented 2 years ago

Resolved by: