File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ """Factory for creating isolated OpenFeature API instances.
2+
3+ Per specification requirement 1.8.3, this module is intentionally separate
4+ from the global singleton ``openfeature.api`` to reduce the risk of
5+ accidentally creating isolated instances when the singleton is appropriate.
6+
7+ Usage::
8+
9+ from openfeature.isolated import create_api
10+
11+ api = create_api()
12+ api.set_provider(MyProvider())
13+ client = api.get_client()
14+
15+ Each instance returned by :func:`create_api` maintains its own providers,
16+ evaluation context, hooks, event handlers, and transaction context propagator
17+ — fully independent from the global singleton and from other instances.
18+
19+ A single provider instance should not be registered with more than one API
20+ instance simultaneously (spec requirement 1.8.4).
21+ """
22+
23+ from openfeature ._api import OpenFeatureAPI
24+
25+ __all__ = ["OpenFeatureAPI" , "create_api" ]
26+
27+
28+ def create_api () -> OpenFeatureAPI :
29+ """Create a new, independent OpenFeature API instance.
30+
31+ The returned instance is functionally equivalent to the global singleton
32+ (``openfeature.api``), but with completely isolated state.
33+
34+ Returns:
35+ A new :class:`OpenFeatureAPI` instance.
36+ """
37+ return OpenFeatureAPI ()
You can’t perform that action at this time.
0 commit comments