open-feature / open-feature/spec
Set context during provider registration when using the static-context paradigm
@beeme1mr is already working on this.
Since Jan 9, 2024.
- Dominant language
- Python
- Stars
- 1.3k
- Forks
- 58
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 2
Description
Overview
When an SDK follows the static-context paradigm, an update to context may lead to an expensive async operation. For that reason, it's recommended to set known context prior to setting the provider. If the context is set later, even immediately after initialization registration, another call to async call may be made.
Set context before set provider
In this scenario, one call is made to the provider during initilzation.
await OpenFeature.setContext({ browser: "chrome" });
await OpenFeature.setProvider(new MyProvider());
Set context after set provider
In this scenario, two calls may be made to the provider because the context changes after initialization.
await OpenFeature.setProvider(new MyProvider());
await OpenFeature.setContext({ browser: "chrome" });
Proposal
await OpenFeature.setProvider(new MyProvider(), { browser: "chrome" });
The proposal would ensure that context is available to the provider during initialization. Context can still be updated using OpenFeature.setContext() if necessary, but this would help users avoid unnecessary delays during start up.
Requirements
- Define the requirements for setting context during provider registration when using the static-context paradigm
Dependencies
References
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.