Skip to content

Commit afe1c7e

Browse files
authored
feat: add domain as an openfeature concept (#229)
Signed-off-by: Michael Beemer <[email protected]>
1 parent 2ad67fc commit afe1c7e

File tree

5 files changed

+61
-39
lines changed

5 files changed

+61
-39
lines changed

specification.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
{
3939
"id": "Requirement 1.1.3",
4040
"machine_id": "requirement_1_1_3",
41-
"content": "The `API` MUST provide a function to bind a given `provider` to one or more client `name`s. If the client-name already has a bound provider, it is overwritten with the new mapping.",
41+
"content": "The `API` MUST provide a function to bind a given `provider` to one or more clients using a `domain`. If the domain already has a bound provider, it is overwritten with the new mapping.",
4242
"RFC 2119 keyword": "MUST",
4343
"children": []
4444
},
@@ -59,7 +59,7 @@
5959
{
6060
"id": "Requirement 1.1.6",
6161
"machine_id": "requirement_1_1_6",
62-
"content": "The `API` MUST provide a function for creating a `client` which accepts the following options: - name (optional): A logical string identifier for the client.",
62+
"content": "The `API` MUST provide a function for creating a `client` which accepts the following options: - domain (optional): A logical string identifier for binding clients to provider.",
6363
"RFC 2119 keyword": "MUST",
6464
"children": []
6565
},
@@ -80,7 +80,7 @@
8080
{
8181
"id": "Requirement 1.2.2",
8282
"machine_id": "requirement_1_2_2",
83-
"content": "The client interface MUST define a `metadata` member or accessor, containing an immutable `name` field or accessor of type string, which corresponds to the `name` value supplied during client creation.",
83+
"content": "The client interface MUST define a `metadata` member or accessor, containing an immutable `domain` field or accessor of type string, which corresponds to the `domain` value supplied during client creation.",
8484
"RFC 2119 keyword": "MUST",
8585
"children": []
8686
},
@@ -523,14 +523,14 @@
523523
{
524524
"id": "Conditional Requirement 3.2.2.3",
525525
"machine_id": "conditional_requirement_3_2_2_3",
526-
"content": "The API MUST have a method for setting `evaluation context` for a provider bound to a named client.",
526+
"content": "The API MUST have a method for setting `evaluation context` for a `domain`.",
527527
"RFC 2119 keyword": "MUST",
528528
"children": []
529529
},
530530
{
531531
"id": "Conditional Requirement 3.2.2.4",
532532
"machine_id": "conditional_requirement_3_2_2_4",
533-
"content": "The API MUST have a a mechanism to manage `evaluation context` for an associated name.",
533+
"content": "The API MUST have a mechanism to manage `evaluation context` for an associated `domain`.",
534534
"RFC 2119 keyword": "MUST",
535535
"children": []
536536
}

specification/glossary.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: A list of terms used within the OpenFeature specification.
44
sidebar_position: 1
55
---
66

7-
# Glossary
7+
# Glossary <!-- omit from toc -->
88

99
This document defines some terms that are used across this specification.
1010

@@ -28,6 +28,7 @@ This document defines some terms that are used across this specification.
2828
- [Evaluation API](#evaluation-api)
2929
- [Flag Management System](#flag-management-system)
3030
- [Provider](#provider)
31+
- [Domain](#domain)
3132
- [Integration](#integration)
3233
- [Evaluation Context](#evaluation-context)
3334
- [Evaluating Flag Values](#evaluating-flag-values)
@@ -107,7 +108,9 @@ A source-of-truth for flag values and rules. Flag management systems may include
107108

108109
An SDK-compliant implementation which resolves flag values from a particular flag management system, allowing the use of the [Evaluation API](./sections/01-flag-evaluation.md#13-flag-evaluation) as an abstraction for the system in question.
109110

110-
Providers can be used in two ways. Client-specific providers are active for specific clients, based on their name. The default provider is used if there are no client-specific mappings setup.
111+
### Domain
112+
113+
An identifier which logically binds clients with providers, allowing for multiple providers to be used simultaneously within a single application.
111114

112115
### Integration
113116

specification/sections/01-flag-evaluation.md

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,29 @@ It's important that multiple instances of the `API` not be active, so that state
3131
OpenFeature.setProvider(new MyProvider());
3232
```
3333

34-
This provider is used if a client is not bound to a specific provider through its name.
34+
The example above sets the default provider.
35+
This provider is used if a client is not bound to a specific provider via a [domain](../glossary.md#domain).
3536

36-
See [provider](./02-providers.md), [creating clients](#creating-clients).
37+
See [provider](./02-providers.md), [creating clients](#creating-clients) for details.
3738

3839
#### Requirement 1.1.2.2
3940

4041
> The `provider mutator` function **MUST** invoke the `initialize` function on the newly registered provider before using it to resolve flag values.
4142
4243
Application authors can await the newly set `provider's` readiness using the `PROVIDER_READY` event.
43-
Provider instances which are already active (because they have been bound to other `names` or otherwise) need not be initialized again.
44+
Provider instances which are already active (because they have been bound to another `domain` or otherwise) need not be initialized again.
4445
The `provider's` readiness can state can be determined from its `status` member/accessor.
4546

46-
See [event handlers and initialization](./05-events.md#event-handlers-and-initialization), [provider initialization](./02-providers.md#24-initialization).
47+
See [event handlers and initialization](./05-events.md#event-handlers-and-initialization), [provider initialization](./02-providers.md#24-initialization), [domain](../glossary.md#domain) for details.
4748

4849
#### Requirement 1.1.2.3
4950

5051
> The `provider mutator` function **MUST** invoke the `shutdown` function on the previously registered provider once it's no longer being used to resolve flag values.
5152
5253
When a provider is no longer in use, it should be disposed of using its `shutdown` mechanism.
53-
Provider instances which are bound to multiple names won't be shut down until the last binding is removed.
54+
Provider instances which are bound to multiple `domains` won't be shut down until the last binding is removed.
5455

55-
see: [shutdown](./02-providers.md#25-shutdown), [setting a provider](#setting-a-provider)
56+
see [shutdown](./02-providers.md#25-shutdown), [setting a provider](#setting-a-provider), [domain](../glossary.md#domain) for details.
5657

5758
#### Requirement 1.1.2.4
5859

@@ -61,28 +62,30 @@ see: [shutdown](./02-providers.md#25-shutdown), [setting a provider](#setting-a-
6162
This function not only sets the provider, but ensures that the provider is ready (or in error) before returning or settling.
6263

6364
```java
64-
// default client
65+
// default provider
6566
OpenFeatureAPI.getInstance().setProviderAndWait(myprovider); // this method blocks until the provider is ready or in error
67+
// client uses the default provider
6668
Client client = OpenFeatureAPI.getInstance().getClient();
6769

68-
// named client
69-
OpenFeatureAPI.getInstance().setProviderAndWait('client-name', myprovider); // this method blocks until the provider is ready or in error
70-
Client client = OpenFeatureAPI.getInstance().getClient('client-name');
70+
// provider associated with domain-1
71+
OpenFeatureAPI.getInstance().setProviderAndWait('domain-1', myprovider); // this method blocks until the provider is ready or in error
72+
// client uses provider associated with the domain named 'domain-1'
73+
Client client = OpenFeatureAPI.getInstance().getClient('domain-1');
7174
```
7275

7376
Though it's possible to use [events](./05-events.md) to await provider readiness, such functions can make things simpler for `application authors` and `integrators`.
7477

7578
#### Requirement 1.1.3
7679

77-
> The `API` **MUST** provide a function to bind a given `provider` to one or more client `name`s. If the client-name already has a bound provider, it is overwritten with the new mapping.
80+
> The `API` **MUST** provide a function to bind a given `provider` to one or more clients using a `domain`. If the domain already has a bound provider, it is overwritten with the new mapping.
7881
7982
```java
80-
OpenFeature.setProvider("client-name", new MyProvider());
83+
OpenFeature.setProvider("domain-1", new MyProvider());
8184
```
8285

83-
Named clients can be associated with a particular provider by supplying a matching name when the provider is set.
86+
Clients can be associated with a particular provider by supplying a matching `domain`` when the provider is set.
8487

85-
See [creating clients](#creating-clients).
88+
See [creating clients](#creating-clients), [domain](../glossary.md#domain) for details.
8689

8790
#### Requirement 1.1.4
8891

@@ -104,25 +107,38 @@ See [hooks](./04-hooks.md) for details.
104107
OpenFeature.getProviderMetadata();
105108
```
106109

107-
See [provider](./02-providers.md) for details.
110+
It's possible to access provider metadata using a `domain`.
111+
If a provider has not be registered under the requested domain, the default provider metadata is returned.
112+
113+
```typescript
114+
// example provider accessor
115+
OpenFeature.getProviderMetadata("domain-1");
116+
```
117+
118+
See [provider](./02-providers.md), [domain](../glossary.md#domain) for details.
108119

109120
### Creating clients
110121

111122
#### Requirement 1.1.6
112123

113124
> The `API` **MUST** provide a function for creating a `client` which accepts the following options:
114125
>
115-
> - name (optional): A logical string identifier for the client.
126+
> - domain (optional): A logical string identifier for binding clients to provider.
116127
117128
```java
118129
// example client creation and retrieval
119-
OpenFeature.getClient("my-named-client");
130+
OpenFeature.getClient();
120131
```
121132

122-
The name is a logical identifier for the client which may be associated with a particular provider by the application integrator.
123-
If a client name is not bound to a particular provider, the client is associated with the default provider.
133+
It's possible to create a client that is associated with a `domain`.
134+
The client will use a provider in the same `domain` if one exists, otherwise, the default provide is used.
124135

125-
See [setting a provider](#setting-a-provider) for details.
136+
```java
137+
// example client creation and retrieval using a domain
138+
OpenFeature.getClient("domain-1");
139+
```
140+
141+
See [setting a provider](#setting-a-provider), [domain](../glossary.md#domain) for details.
126142

127143
#### Requirement 1.1.7
128144

@@ -145,12 +161,15 @@ See [hooks](./04-hooks.md) for details.
145161

146162
#### Requirement 1.2.2
147163

148-
> The client interface **MUST** define a `metadata` member or accessor, containing an immutable `name` field or accessor of type string, which corresponds to the `name` value supplied during client creation.
164+
> The client interface **MUST** define a `metadata` member or accessor, containing an immutable `domain` field or accessor of type string, which corresponds to the `domain` value supplied during client creation.
149165
150166
```typescript
151-
client.getMetadata().getName(); // "my-client"
167+
client.getMetadata().getDomain(); // "domain-1"
152168
```
153169

170+
In previous drafts, this property was called `name`.
171+
For backwards compatibility, implementations should consider `name` an alias to `domain`.
172+
154173
### 1.3. Flag Evaluation
155174

156175
[![hardening](https://img.shields.io/static/v1?label=Status&message=hardening&color=yellow)](https://github.com/open-feature/spec/tree/main/specification#hardening)

specification/sections/03-evaluation-context.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,19 @@ In the static-context paradigm, context is global. The client and invocation can
7979

8080
##### Conditional Requirement 3.2.2.3
8181

82-
> The API **MUST** have a method for setting `evaluation context` for a provider bound to a named client.
82+
> The API **MUST** have a method for setting `evaluation context` for a `domain`.
8383
84-
In the static-context paradigm, provider specific context can be set using the associated name.
84+
In the static-context paradigm, provider specific context can be set using the associated `domain`.
8585
The global context is used if there is no matching provider specific context.
8686

87-
See [setting a provider](./01-flag-evaluation.md#setting-a-provider) for details.
87+
See [setting a provider](./01-flag-evaluation.md#setting-a-provider), [domain](../glossary.md#domain) for details.
8888

8989
##### Conditional Requirement 3.2.2.4
9090

91-
> The API **MUST** have a a mechanism to manage `evaluation context` for an associated name.
91+
> The API **MUST** have a mechanism to manage `evaluation context` for an associated `domain`.
9292
93-
In the static-context paradigm, it must be possible to create and remove provider-specific context.
94-
See [setting a provider](./01-flag-evaluation.md#setting-a-provider) for details.
93+
In the static-context paradigm, it's possible to create and remove provider-specific context.
94+
See [setting a provider](./01-flag-evaluation.md#setting-a-provider), [domain](../glossary.md#domain) for details.
9595

9696
#### Requirement 3.2.3
9797

specification/sections/05-events.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ see: [provider event types](./../types.md#provider-events) and [event handlers](
4242

4343
> When a `provider` signals the occurrence of a particular `event`, event handlers on clients which are not associated with that provider **MUST NOT** run.
4444
45-
Providers bound to a named client constitute their own "events scope".
45+
Providers bound to a `domain` constitute their own "events scope".
4646

47-
see: [setting a provider](./01-flag-evaluation.md#setting-a-provider)
47+
see [setting a provider](./01-flag-evaluation.md#setting-a-provider), [domain](../glossary.md#domain) for details.
4848

4949
#### Requirement 5.1.4
5050

@@ -83,9 +83,9 @@ see: [provider events](#51-provider-events), [`provider event types`](../types.m
8383
> The `event details` **MUST** contain the `provider name` associated with the event.
8484
8585
The `provider name` indicates the provider from which the event originated.
86-
This is especially relevant for global event handlers used for general monitoring, such as alerting on provider errors.
86+
This is especially relevant for global event handlers used for general monitoring, such as alerting on provider errors.
8787

88-
See [setting a provider](./01-flag-evaluation.md#setting-a-provider), [creating clients](./01-flag-evaluation.md#creating-clients).
88+
See [setting a provider](./01-flag-evaluation.md#setting-a-provider), [creating clients](./01-flag-evaluation.md#creating-clients).
8989

9090
#### Requirement 5.2.4
9191

0 commit comments

Comments
 (0)