Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@openfeature/flagd-provider
Advanced tools
This provider is designed to use flagd's [evaluation protocol](https://github.com/open-feature/schemas/blob/main/protobuf/schema/v1/schema.proto), or locally evaluate flags defined in a flagd [flag definition](https://github.com/open-feature/schemas/blob/
This provider is designed to use flagd's evaluation protocol, or locally evaluate flags defined in a flagd flag definition. This repository and package provides the client code for interacting with it via the OpenFeature server-side JavaScript SDK.
npm install @openfeature/flagd-provider
yarn add @openfeature/server-sdk @grpc/grpc-js @openfeature/flagd-core
[!NOTE] yarn requires manual installation of peer dependencies
The FlagdProvider
supports multiple configuration options and has the ability to resolve flags remotely over RPC or in-process.
Options can be defined in the constructor or as environment variables. Constructor options having the highest precedence.
Option name | Environment variable name | Type | Default | Supported values |
---|---|---|---|---|
host | FLAGD_HOST | string | localhost | |
port | FLAGD_PORT | number | resolver specific defaults | |
tls | FLAGD_TLS | boolean | false | |
socketPath | FLAGD_SOCKET_PATH | string | - | |
resolverType | FLAGD_RESOLVER | string | rpc | rpc, in-process |
offlineFlagSourcePath | FLAGD_OFFLINE_FLAG_SOURCE_PATH | string | - | |
selector | FLAGD_SOURCE_SELECTOR | string | - | |
cache | FLAGD_CACHE | string | lru | lru, disabled |
maxCacheSize | FLAGD_MAX_CACHE_SIZE | int | 1000 | |
defaultAuthority | FLAGD_DEFAULT_AUTHORITY | string | - | rpc, in-process |
Option name | Environment variable name | in-process | rpc | default |
---|---|---|---|---|
port | FLAGD_PORT | 8015 | 8013 | 8013 |
Below are examples of usage patterns.
This is the default mode of operation of the provider. In this mode, FlagdProvider communicates with flagd via the gRPC protocol. Flag evaluations take place remotely on the connected flagd instance.
OpenFeature.setProvider(new FlagdProvider())
In the above example, the provider expects flagd to be available at localhost:8013
(default host and port).
Alternatively, you can use socket paths to connect to flagd.
OpenFeature.setProvider(new FlagdProvider({
socketPath: "/tmp/flagd.socks",
}))
This mode performs flag evaluations locally (in-process). Flag configurations for evaluation are obtained via gRPC protocol using sync protobuf schema service definition.
OpenFeature.setProvider(new FlagdProvider({
resolverType: 'in-process',
}))
In the above example, the provider expects a flag sync service implementation to be available at localhost:8015
(default host and port).
In-process resolver can also work in an offline mode.
To enable this mode, you should provide a valid flag configuration file with the option offlineFlagSourcePath
.
OpenFeature.setProvider(new FlagdProvider({
resolverType: 'in-process',
offlineFlagSourcePath: './flags.json',
}))
Offline mode uses fs.watchFile
and polls every 5 seconds for changes to the file.
This mode is useful for local development, test cases, and for offline applications.
This is useful for complex routing or service-discovery use cases that involve a proxy (e.g., Envoy). Please refer to this GitHub issue for more information.
OpenFeature.setProvider(new FlagdProvider({
resolverType: 'in-process',
defaultAuthority: 'b-target-api.service',
}))
The flagd provider emits PROVIDER_READY
, PROVIDER_ERROR
and PROVIDER_CONFIGURATION_CHANGED
events.
SDK event | Originating action in flagd |
---|---|
PROVIDER_READY | The streaming connection with flagd has been established. |
PROVIDER_ERROR | The streaming connection with flagd has been broken. |
PROVIDER_CONFIGURATION_CHANGED | A flag configuration (default value, targeting rule, etc) in flagd has changed. |
For general information on events, see the official documentation.
Flag metadata is a set of key-value pairs that can be associated with a flag. The values come from the flag definition in flagd.
Run nx package providers-flagd
to build the library.
NOTE: Buf must be installed to build locally.
Run nx test providers-flagd
to execute the unit tests via Jest.
FAQs
This provider is designed to use flagd's [evaluation protocol](https://github.com/open-feature/schemas/blob/main/protobuf/schema/v1/schema.proto), or locally evaluate flags defined in a flagd [flag definition](https://github.com/open-feature/schemas/blob/
The npm package @openfeature/flagd-provider receives a total of 4,261 weekly downloads. As such, @openfeature/flagd-provider popularity was classified as popular.
We found that @openfeature/flagd-provider demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.