Skip to content

Commit c1339ba

Browse files
feat: multi-provider docs updates (#1086)
## This PR - Documentation updates for the multi-provider. - providing clarity between domain-scoped multiple providers + clients and mutli-provider --------- Signed-off-by: Jonathan Norris <[email protected]> Co-authored-by: Michael Beemer <[email protected]>
1 parent facaae3 commit c1339ba

File tree

3 files changed

+59
-11
lines changed

3 files changed

+59
-11
lines changed

blog/2023-05-24-spec-0-6-0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ We are excited to announce the availability of version 0.6.0 of the OpenFeature
1919

2020
OpenFeature now supports multiple providers in a single application, allowing teams to scope flag evaluation to a particular flag management system. This makes it easier for developers to mix and match providers based on their needs, all from a unified SDK.
2121

22-
> To learn more, please refer to the [OpenFeature Enhancement Proposal](https://github.com/open-feature/ofep/blob/main/OFEP-provider-client-mapping.md) or [spec change](https://openfeature.dev/specification/sections/flag-evaluation/#requirement-113).
22+
> To learn more, please refer to the [OpenFeature Enhancement Proposal](https://github.com/open-feature/ofep/blob/main/OFEP/provider-client-mapping.md) or [spec change](https://openfeature.dev/specification/sections/flag-evaluation/#requirement-113).
2323
2424

2525
### Flag metadata

docs/reference/concepts/02-provider.mdx

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,42 @@ However, the following items should be used in the package name:
8080

8181
An example of what it could look like in NPM: `@openfeature/flagd-provider`
8282

83-
#### Multi-provider support
83+
### Domain scopped providers
8484

85-
OpenFeature supports multiple providers in a single application, allowing teams to scope flag evaluation to a particular flag management system.
86-
This makes it easier for developers to mix and match providers based on their needs, all from a unified SDK.
85+
OpenFeature supports multiple providers [domain-scoped](https://openfeature.dev/specification/glossary/#domain) to multiple clients in a single application.
86+
This allows teams to scope flag evaluation to a particular flag management system, making it easier for developers to mix and match providers based on their needs, all from a unified SDK.
8787

88-
> To learn more, please refer to the [OpenFeature Enhancement Proposal](https://github.com/open-feature/ofep/blob/main/OFEP-provider-client-mapping.md) or [spec change](https://openfeature.dev/specification/sections/flag-evaluation/#requirement-113).
88+
```typescript
89+
OpenFeature.setProvider('ProviderA', new ProviderA());
90+
OpenFeature.setProvider('ProviderB', new ProviderB());
91+
92+
const clientA = OpenFeature.getClient('ProviderA');
93+
const clientB = OpenFeature.getClient('ProviderB');
94+
```
95+
96+
> To learn more, please refer to the [OpenFeature Enhancement Proposal](https://github.com/open-feature/ofep/blob/main/OFEP/provider-client-mapping.md) or [spec change](https://openfeature.dev/specification/sections/flag-evaluation/#requirement-113).
97+
98+
### Multi-Provider support
99+
100+
OpenFeature SDKs also support combining multiple providers under a single client using the [Multi-Provider specification](/specification/appendix-a#multi-provider).
101+
This interface allows your application to transparently interact with multiple providers from different flag management systems through a single interface.
102+
The logic of how the different providers are accessed through the multi-provider is handled through the assigned [multi-provider strategy](/specification/appendix-a#strategies).
103+
104+
```typescript
105+
const multiProvider = new MultiProvider(
106+
[
107+
{
108+
provider: new ProviderA(),
109+
},
110+
{
111+
provider: new ProviderB(),
112+
},
113+
],
114+
new FirstMatchStrategy(),
115+
);
116+
117+
await OpenFeature.setProviderAndWait(multiProvider);
118+
```
89119

90120
### Examples
91121

@@ -95,7 +125,13 @@ This makes it easier for developers to mix and match providers based on their ne
95125
<TabItem value="js" label="TypeScript">
96126

97127
```ts
98-
import { Provider, ResolutionDetails, EvaluationContext, JsonValue, OpenFeatureEventEmitter } from '@openfeature/server-sdk';
128+
import {
129+
Provider,
130+
ResolutionDetails,
131+
EvaluationContext,
132+
JsonValue,
133+
OpenFeatureEventEmitter,
134+
} from '@openfeature/server-sdk';
99135

100136
export class MyFeatureProvider implements Provider {
101137
readonly metadata = {
@@ -110,31 +146,31 @@ export class MyFeatureProvider implements Provider {
110146
resolveBooleanEvaluation(
111147
flagKey: string,
112148
defaultValue: boolean,
113-
context: EvaluationContext
149+
context: EvaluationContext,
114150
): Promise<ResolutionDetails<boolean>> {
115151
// code to resolve boolean details
116152
}
117153

118154
resolveStringEvaluation(
119155
flagKey: string,
120156
defaultValue: string,
121-
context: EvaluationContext
157+
context: EvaluationContext,
122158
): Promise<ResolutionDetails<string>> {
123159
// code to resolve string details
124160
}
125161

126162
resolveNumberEvaluation(
127163
flagKey: string,
128164
defaultValue: number,
129-
context: EvaluationContext
165+
context: EvaluationContext,
130166
): Promise<ResolutionDetails<number>> {
131167
// code to resolve number details
132168
}
133169

134170
resolveObjectEvaluation(
135171
flagKey: string,
136172
defaultValue: JsonValue,
137-
context: EvaluationContext
173+
context: EvaluationContext,
138174
): Promise<ResolutionDetails<JsonValue>> {
139175
// code to resolve object details
140176
}

src/datasets/providers/multi-provider.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,21 @@ export const MultiProvider: Provider = {
88
technologies: [
99
{
1010
technology: 'JavaScript',
11-
vendorOfficial: true,
11+
vendorOfficial: false,
1212
href: 'https://github.com/open-feature/js-sdk-contrib/tree/main/libs/providers/multi-provider',
1313
category: ['Server'],
1414
},
15+
{
16+
technology: 'JavaScript',
17+
vendorOfficial: false,
18+
href: 'https://github.com/open-feature/js-sdk-contrib/tree/main/libs/providers/multi-provider-web',
19+
category: ['Client'],
20+
},
21+
{
22+
technology: 'Java',
23+
vendorOfficial: false,
24+
href: 'https://github.com/open-feature/java-sdk-contrib/tree/main/providers/multiprovider',
25+
category: ['Server'],
26+
},
1527
],
1628
};

0 commit comments

Comments
 (0)