@openfeature/flagd-provider 0.9.0 → 0.10.1

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 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
- $ npm install @openfeature/flagd-provider
9
+ ### npm
10
+
11
+ ```sh
12
+ npm install @openfeature/flagd-provider
11
13
  ```
12
14
 
13
- Required peer dependencies
15
+ ### yarn
14
16
 
17
+ ```sh
18
+ yarn add @openfeature/server-sdk @grpc/grpc-js @openfeature/flagd-core
15
19
  ```
16
- $ npm install @openfeature/server-sdk
17
- ```
18
20
 
19
- ## Usage
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
- The `FlagdProvider` supports multiple configuration options that determine now the SDK communicates with flagd.
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
- ### Available Options
44
+ ### Remote flag resolving over RPC
25
45
 
26
- | Option name | Environment variable name | Type | Default | Values |
27
- | --------------------- | ------------------------------ | ------- | --------- | ------------ |
28
- | host | FLAGD_HOST | string | localhost | |
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
- ### Example Using TCP
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
- host: 'localhost',
41
- port: 8013,
60
+ socketPath: "/tmp/flagd.socks",
42
61
  }))
43
62
  ```
44
63
 
45
- ### Example Using a Unix Socket
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
- socketPath: "/tmp/flagd.socks",
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.