You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Add isolated API instance functionality (#740)
* feat: add tracking for bound API instance in FeatureProvider
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
* feat: clear ownership of bound API instances during provider shutdown
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
* feat: add CreateIsolated method and provider ownership validation to Api class
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
* feat: add unit tests for isolated API instances and provider behavior
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
* feat: add demonstration of isolated API instance creation and usage
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
* feat: add isolated API instance testing functionality
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
* Fix formatting
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
* test: enhance exception message assertions for provider binding in isolated API tests
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
* Apply suggestions from code review
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
* refactor: improve provider instance binding logic
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
* Move to a separate namespace.
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
* feat: add experimental identifiers for Isolated API features and update related code
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
* fix: reorder using directives for consistency in IsolatedApiTests
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
---------
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Copy file name to clipboardExpand all lines: samples/Console/README.md
+11Lines changed: 11 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,3 +43,14 @@ The sample defines the following flags using the `InMemoryProvider`:
43
43
## NativeAOT
44
44
45
45
This sample is published with [NativeAOT](https://learn.microsoft.com/dotnet/core/deploying/native-aot/) enabled (`PublishAot=true`), demonstrating that the OpenFeature .NET SDK is fully compatible with NativeAOT compilation. See the [AOT Compatibility Guide](../../../docs/AOT_COMPATIBILITY.md) for more details.
46
+
47
+
## Isolated API Instance
48
+
49
+
The sample also demonstrates how to create an **isolated API instance** using `Api.CreateIsolated()`. The isolated instance has its own provider with different flag values, proving that it operates independently from the global singleton.
The isolated instance evaluates flags from its own provider, then shuts down without affecting the global singleton. This is useful for testing, multi-tenant applications, and dependency injection scenarios. See the [specification](https://openfeature.dev/specification/sections/flag-evaluation#18-isolated-api-instances) for more details.
/// Factory for creating isolated instances of the OpenFeature API.
9
+
/// </summary>
10
+
/// <remarks>
11
+
/// This factory provides a method to create new, independent instances of the OpenFeature API with fully isolated state. Each isolated instance maintains its own providers, evaluation context, hooks, event handlers,
12
+
/// and transaction context propagators. It does not share state with the global <see cref="Api.Instance"/> singleton or with any other isolated instance.
13
+
/// </remarks>
14
+
publicstaticclassOpenFeatureFactory
15
+
{
16
+
/// <summary>
17
+
/// Creates a new, independent instance of the OpenFeature API with fully isolated state.
18
+
/// <para>
19
+
/// Each isolated instance maintains its own providers, evaluation context, hooks, event handlers,
20
+
/// and transaction context propagators. It does not share state with the global <see cref="Api.Instance"/>
21
+
/// singleton or with any other isolated instance.
22
+
/// </para>
23
+
/// </summary>
24
+
/// <remarks>
25
+
/// <para>
26
+
/// A single provider instance should not be bound to more than one API instance at a time.
27
+
/// Attempting to do so will result in an <see cref="InvalidOperationException"/>.
0 commit comments