Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 1 addition & 73 deletions libs/providers/flagd-web/README.md
Original file line number Diff line number Diff line change
@@ -1,75 +1,3 @@
# flagd-web Provider for OpenFeature

![Experimental](https://img.shields.io/badge/experimental-breaking%20changes%20allowed-yellow)

A feature flag daemon with a Unix philosophy.

## Installation

:warning: This provider requires the use of the experimental @openfeature/web-sdk:

```
npm install @openfeature/web-sdk
```

```sh
npm install @openfeature/flagd-web-provider
```

## Usage

The `FlagdWebProvider` communicates with flagd via the [connect protocol](https://buf.build/blog/connect-a-better-grpc).

### Available options

| Option name | Type | Default | Description |
| ----------- | ------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| host | string | | sets the host used to connect to the flagd instance |
| pathPrefix | string | "" | sets the path at which the flagd gRPC service is available, for example: `/api/flagd` (optional) |
| port | number | 443 | sets the port used to connect to the flagd instance |
| tls | boolean | true | when set to true the provider will attempt to connect to flagd via https |
| maxRetries | number | 0 | Sets the maximum number of retries for a connection to be made to the flagd instance. A value of 0 means unlimited. A negative value means no retries. |
| maxDelay | number | 60000 | sets the maximum time in ms to wait between reconnect intervals |

### Reconnection

If the connection to the flagd instance fails, the provider will attempt to reconnect with an exponential back-off. The `maxDelay` and `maxRetries` can be specified to customize reconnect behavior.

### Event streaming

The `FlagdWebProvider` receives events from flagd with changes. Combined with the event API in the web SDK, this allows for subscription to flag value changes in clients.

```typescript
client.addHandler(ProviderEvents.Ready, () => {
// do something when the configuration has changed.
});
```

### Caching

The `FlagdWebProvider` evaluates flags in bulk, taking into account the evaluation context, and then caches them in memory for local evaluation.
The cache is invalidated when flag configuration change events are received.

## Example

```typescript
OpenFeature.setProvider(
new FlagdWebProvider({
host: 'myapp.com',
port: 443,
tls: true,
maxRetries: 10,
maxDelay: 30000,
})
);
```

## Building

Run `npx nx package flagd-web` to build the library.

> NOTE: [Buf](https://docs.buf.build/installation) must be installed to build locally.

## Running unit tests

Run `npx nx test flagd-web` to execute the unit tests via [Jest](https://jestjs.io).
> **⚠️ DEPRECATED**: This package is deprecated and has been superseded by the OFREP provider, which is supported by flagd and offers comparable features. Please migrate to the [NPM package](https://www.npmjs.com/package/@openfeature/ofrep-web-provider) ([source on GitHub](https://github.com/open-feature/js-sdk-contrib/tree/main/libs/providers/ofrep-web)).
3 changes: 3 additions & 0 deletions libs/providers/flagd-web/src/lib/flagd-web-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ const BACK_OFF_MULTIPLIER = 2;
const INITIAL_DELAY_MS = 100;
type AnyFlagResolutionType = typeof AnyFlag.prototype.value.case;

/**
* @deprecated use OFREPWebProvider from '@openfeature/ofrep-web-provider'
*/
export class FlagdWebProvider implements Provider {
metadata = {
name: 'flagd',
Expand Down