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
Copy file name to clipboardExpand all lines: specification.json
+28Lines changed: 28 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -365,6 +365,34 @@
365
365
"RFC 2119 keyword": "MUST",
366
366
"children": []
367
367
},
368
+
{
369
+
"id": "Requirement 1.8.1",
370
+
"machine_id": "requirement_1_8_1",
371
+
"content": "The `API` MUST expose a factory function which creates and returns a new, independent instance of the `API`.",
372
+
"RFC 2119 keyword": "MUST",
373
+
"children": []
374
+
},
375
+
{
376
+
"id": "Requirement 1.8.2",
377
+
"machine_id": "requirement_1_8_2",
378
+
"content": "Instances returned by the factory function MUST conform to the same `API` contract as the global singleton, including flag evaluation, provider management, context, hooks, events, and shutdown functionality.",
379
+
"RFC 2119 keyword": "MUST",
380
+
"children": []
381
+
},
382
+
{
383
+
"id": "Requirement 1.8.3",
384
+
"machine_id": "requirement_1_8_3",
385
+
"content": "The factory function for creating isolated instances SHOULD be housed in a distinct module, import path, package, or namespace from the global singleton `API`.",
386
+
"RFC 2119 keyword": "SHOULD",
387
+
"children": []
388
+
},
389
+
{
390
+
"id": "Requirement 1.8.4",
391
+
"machine_id": "requirement_1_8_4",
392
+
"content": "A `provider` instance SHOULD NOT be registered with more than one `API` instance simultaneously.",
@@ -125,6 +126,10 @@ The possible states and transitions of a provider over the course of its usage,
125
126
126
127
An identifier which logically binds clients with providers, allowing for multiple providers to be used simultaneously within a single application. Domain binding is dynamic; it may change over the course of an application's lifetime (i.e.: a client associated with the default provider via an unbound domain will be bound to a new provider if a provider is subsequently assigned to that domain).
127
128
129
+
### Isolated API Instance
130
+
131
+
An independent, non-singleton instance of the [Feature Flag API](#feature-flag-api) created via a factory function. Each isolated instance maintains its own state, including providers, evaluation context, hooks, and event handlers. Isolated instances do not share state with the global singleton or with each other. Intended for advanced use cases such as micro-frontend architectures, dependency injection frameworks, and testing scenarios.
132
+
128
133
### Integration
129
134
130
135
An SDK-compliant secondary function that is abstracted by the Feature Flag API, and requires only minimal configuration by the Application Author. Examples include telemetry, tracking, custom logging and monitoring.
> The client's `provider status` accessor **MUST** indicate `NOT_READY` once the `shutdown` function of the associated provider terminates.
531
531
532
532
Regardless of the success of the provider's `shutdown` function, the `provider status` should convey the provider is no longer ready to use once the shutdown function terminates.
While the `API`[functions as a global singleton](#requirement-111) in the default case, certain use cases require independent instances of the `API` with fully isolated state. Examples include micro-frontend architectures (where separately developed applications coexist in a single runtime), dependency injection frameworks and IoC containers (which manage object lifecycles outside the singleton's scope), testing scenarios (where parallel tests mutating shared state can interfere with each other), and server-side applications composed of multiple submodules each requiring distinct providers.
539
+
540
+
#### Requirement 1.8.1
541
+
542
+
> The `API`**MUST** expose a factory function which creates and returns a new, independent instance of the `API`.
543
+
544
+
Each instance returned by this factory function maintains its own state, including providers, `evaluation context`, hooks, event handlers, and transaction context propagators.
545
+
Instances created by the factory function do not share state with the "default" global singleton or with each other.
See [application integrator](../glossary.md#application-integrator), [isolated API instance](../glossary.md#isolated-api-instance) for details.
555
+
556
+
#### Requirement 1.8.2
557
+
558
+
> Instances returned by the factory function **MUST** conform to the same `API` contract as the global singleton, including flag evaluation, provider management, context, hooks, events, and shutdown functionality.
559
+
560
+
An isolated `API` instance is functionally equivalent to the global singleton, but with independent state.
561
+
Application code which uses a `client` obtained from an isolated instance behaves identically to code using a `client` from the global singleton.
562
+
563
+
#### Requirement 1.8.3
564
+
565
+
> The factory function for creating isolated instances **SHOULD** be housed in a distinct module, import path, package, or namespace from the global singleton `API`.
566
+
567
+
The factory function should be intentionally less discoverable than the default singleton, reducing the risk of `application authors` inadvertently creating isolated instances when the singleton would be more appropriate.
568
+
The distinct import path serves as an explicit signal that the consumer is opting into advanced, non-default behavior.
569
+
570
+
```typescript
571
+
// example: the factory function is accessed from a distinct module
> A `provider` instance **SHOULD NOT** be registered with more than one `API` instance simultaneously.
578
+
579
+
Because the `API` instance manages the [lifecycle](./02-providers.md) of its associated providers (including initialization, shutdown, and event handling), binding a `provider` to more than one `API` instance could result in undefined behavior.
580
+
A `provider` instance can be registered with multiple `domains` within a single `API` instance.
581
+
When a provider is no longer associated with an `API` instance, it can be registered to another.
582
+
583
+
See [setting a provider](#setting-a-provider), [domain](../glossary.md#domain) for details.
0 commit comments