|
1 | 1 | # In-Memory Provider |
2 | 2 |
|
3 | | -An *extremely* simple OpenFeature provider, intended for simple demos and as a test stub. |
4 | | - |
5 | | -Flagging decisions are static - evaluation context is ignored. The only way to change a flag value is |
6 | | -to replace the entire configuration (with `replaceConfiguration`), and this is only intended to be used |
7 | | -when the provider is acting as a test stub. |
8 | | - |
9 | | -Object values are not currently supported (but a PR implementing them would be gratefully received!) |
10 | | - |
11 | | -## Installation |
12 | | - |
13 | | -``` |
14 | | -$ npm install @openfeature/in-memory-provider |
15 | | -``` |
16 | | - |
17 | | -## Usage |
18 | | - |
19 | | -### set up the provider with some flag values |
20 | | -``` |
21 | | -import { InMemoryProvider } from '@openfeature/in-memory-provider' |
22 | | -import { OpenFeature } from '@openfeature/server-sdk' |
23 | | -
|
24 | | -const flags = { |
25 | | - 'a-boolean-flag': true, |
26 | | - 'a-string-flag': 'the flag value', |
27 | | -} |
28 | | -const provider = new InMemoryProvider(flags) |
29 | | -OpenFeature.setProvider(provider) |
30 | | -``` |
31 | | - |
32 | | -### check a flag's value |
33 | | -``` |
34 | | -// create a client |
35 | | -const client = OpenFeature.getClient('my-app'); |
36 | | -
|
37 | | -// get that hardcoded boolean flag |
38 | | -const boolValue = await client.getBooleanValue('a-boolean-flag', false); |
39 | | -``` |
40 | | - |
41 | | -### replace the flag configuration |
42 | | -*a crude facility for when the provider is being used as a test stub* |
43 | | - |
44 | | -``` |
45 | | -provider.replaceConfiguration({ |
46 | | - 'a-boolean-flag': false |
47 | | -}) |
48 | | -``` |
49 | | - |
50 | | -Note that this entirely replaces the previous configuration - no merging is |
51 | | -performed and all previous values are lost. |
52 | | - |
53 | | - |
54 | | -## Development |
55 | | - |
56 | | -Run `nx package providers-in-memory` to build the library. |
57 | | - |
58 | | -Run `nx test providers-in-memory` to execute the unit tests via [Jest](https://jestjs.io). |
| 3 | +This component has been deprecated and removed. |
| 4 | +The `@openfeature/server-sdk` now contains its own `InMemoryProvider` implementation. |
0 commit comments