@openfeature/flagd-provider 0.8.3 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -23
- package/index.cjs.d.ts +1 -0
- package/index.cjs.default.js +1 -0
- package/{index.cjs → index.cjs.js} +574 -176
- package/index.cjs.mjs +2 -0
- package/{index.js → index.esm.js} +560 -162
- package/package.json +15 -14
- package/src/e2e/jest.config.d.ts +12 -0
- package/src/e2e/setup-in-process-provider.d.ts +1 -0
- package/src/e2e/setup-rpc-provider.d.ts +1 -0
- package/src/e2e/tear-down.d.ts +2 -0
- package/src/lib/configuration.d.ts +18 -7
- package/src/lib/constants.d.ts +1 -1
- package/src/lib/flagd-provider.d.ts +9 -8
- package/src/lib/service/grpc/grpc-service.d.ts +9 -18
- package/src/lib/service/in-process/data-fetch.d.ts +7 -0
- package/src/lib/service/in-process/grpc/grpc-fetch.d.ts +18 -0
- package/src/lib/service/in-process/in-process-service.d.ts +16 -0
- package/src/lib/service/service.d.ts +5 -5
- package/src/proto/ts/flagd/evaluation/v1/evaluation.d.ts +956 -0
- package/src/proto/ts/flagd/sync/v1/sync.d.ts +278 -0
- package/src/proto/ts/google/protobuf/struct.d.ts +1 -1
- package/src/proto/ts/schema/v1/schema.d.ts +7 -0
- package/src/proto/ts/sync/v1/sync_service.d.ts +6 -0
package/README.md
CHANGED
|
@@ -6,50 +6,74 @@ This repository and package provides the client code for interacting with it via
|
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
### npm
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install @openfeature/flagd-provider
|
|
11
13
|
```
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
### yarn
|
|
14
16
|
|
|
17
|
+
```sh
|
|
18
|
+
yarn add @openfeature/server-sdk @grpc/grpc-js @openfeature/flagd-core
|
|
15
19
|
```
|
|
16
|
-
$ npm install @openfeature/js-sdk
|
|
17
|
-
```
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
> [!NOTE]
|
|
22
|
+
> yarn requires manual installation of peer dependencies
|
|
23
|
+
|
|
24
|
+
## Configurations and Usage
|
|
25
|
+
|
|
26
|
+
The `FlagdProvider` supports multiple configuration options and has the ability to resolve flags remotely over RPC or in-process.
|
|
27
|
+
Options can be defined in the constructor or as environment variables. Constructor options having the highest precedence.
|
|
28
|
+
|
|
29
|
+
### Available Configuration Options
|
|
30
|
+
|
|
31
|
+
| Option name | Environment variable name | Type | Default | Supported values |
|
|
32
|
+
| -------------------------------------- | ------------------------------ | ------- | --------- | ---------------- |
|
|
33
|
+
| host | FLAGD_HOST | string | localhost | |
|
|
34
|
+
| port | FLAGD_PORT | number | 8013 | |
|
|
35
|
+
| tls | FLAGD_TLS | boolean | false | |
|
|
36
|
+
| socketPath | FLAGD_SOCKET_PATH | string | - | |
|
|
37
|
+
| resolverType | FLAGD_SOURCE_RESOLVER | string | rpc | rpc, in-process |
|
|
38
|
+
| selector | FLAGD_SOURCE_SELECTOR | string | - | |
|
|
39
|
+
| cache | FLAGD_CACHE | string | lru | lru,disabled |
|
|
40
|
+
| maxCacheSize | FLAGD_MAX_CACHE_SIZE | int | 1000 | |
|
|
20
41
|
|
|
21
|
-
|
|
22
|
-
Options can be defined in the constructor or as environment variables, with constructor options having the highest precedence.
|
|
42
|
+
Below are examples of usage patterns.
|
|
23
43
|
|
|
24
|
-
###
|
|
44
|
+
### Remote flag resolving over RPC
|
|
25
45
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
| port | FLAGD_PORT | number | 8013 | |
|
|
30
|
-
| tls | FLAGD_TLS | boolean | false | |
|
|
31
|
-
| socketPath | FLAGD_SOCKET_PATH | string | - | |
|
|
32
|
-
| cache | FLAGD_CACHE | string | lru | lru,disabled |
|
|
33
|
-
| maxCacheSize | FLAGD_MAX_CACHE_SIZE | int | 1000 | |
|
|
34
|
-
| maxEventStreamRetries | FLAGD_MAX_EVENT_STREAM_RETRIES | int | 5 | |
|
|
46
|
+
This is the default mode of operation of the provider.
|
|
47
|
+
In this mode, FlagdProvider communicates with flagd via the gRPC protocol.
|
|
48
|
+
Flag evaluations take place remotely at the connected [flagd](https://flagd.dev/) instance.
|
|
35
49
|
|
|
36
|
-
|
|
50
|
+
```ts
|
|
51
|
+
OpenFeature.setProvider(new FlagdProvider())
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
In the above example, the provider expects flagd to be available at `localhost:8013` (default host and port).
|
|
55
|
+
|
|
56
|
+
Alternatively, you can use socket paths to connect to flagd.
|
|
37
57
|
|
|
38
58
|
```
|
|
39
59
|
OpenFeature.setProvider(new FlagdProvider({
|
|
40
|
-
|
|
41
|
-
port: 8013,
|
|
60
|
+
socketPath: "/tmp/flagd.socks",
|
|
42
61
|
}))
|
|
43
62
|
```
|
|
44
63
|
|
|
45
|
-
###
|
|
64
|
+
### In-process resolver
|
|
65
|
+
|
|
66
|
+
This mode performs flag evaluations locally (in-process).
|
|
67
|
+
Flag configurations for evaluation are obtained via gRPC protocol using [sync protobuf schema](https://buf.build/open-feature/flagd/file/main:sync/v1/sync_service.proto) service definition.
|
|
46
68
|
|
|
47
69
|
```
|
|
48
70
|
OpenFeature.setProvider(new FlagdProvider({
|
|
49
|
-
|
|
71
|
+
resolverType: 'in-process',
|
|
50
72
|
}))
|
|
51
73
|
```
|
|
52
74
|
|
|
75
|
+
In the above example, the provider expects a flag sync service implementation to be available at `localhost:8013` (default host and port).
|
|
76
|
+
|
|
53
77
|
### Supported Events
|
|
54
78
|
|
|
55
79
|
The flagd provider emits `PROVIDER_READY`, `PROVIDER_ERROR` and `PROVIDER_CONFIGURATION_CHANGED` events.
|
package/index.cjs.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/index";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
exports._default = require('./index.cjs.js').default;
|