npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@openfeature/go-feature-flag-web-provider

v0.2.0

Published

[GO Feature Flag](https://gofeatureflag.org) provider allows you to connect to your GO Feature Flag instance with the `@openfeature/web-sdk`.

Downloads

1,398

Readme

go-feature-flag-web Provider for OpenFeature

About this provider

GO Feature Flag provider allows you to connect to your GO Feature Flag instance with the @openfeature/web-sdk.

The main difference between this provider and @openfeature/go-feature-flag-provider is that it uses a static evaluation context.
This provider is more sustainable for client-side implementation.

If you want to know more about this pattern, I encourage you to read this blog post.

What is GO Feature Flag?

GO Feature Flag is a simple, complete and lightweight self-hosted feature flag solution 100% Open Source.
Our focus is to avoid any complex infrastructure work to use GO Feature Flag.

This is a complete feature flagging solution with the possibility to target only a group of users, use any types of flags, store your configuration in various location and advanced rollout functionality. You can also collect usage data of your flags and be notified of configuration changes.

Install the provider

npm install @openfeature/go-feature-flag-web-provider @openfeature/web-sdk

How to use the provider?

const evaluationCtx: EvaluationContext = {
  targetingKey: 'user-key',
  email: '[email protected]',
  name: 'John Doe',
};

const goFeatureFlagWebProvider = new GoFeatureFlagWebProvider({
  endpoint: endpoint,
  // ...
}, logger);

await OpenFeature.setContext(evaluationCtx); // Set the static context for OpenFeature
OpenFeature.setProvider(goFeatureFlagWebProvider); // Attach the provider to OpenFeature
const client = await OpenFeature.getClient();

// You can now use the client to use your flags
if(client.getBooleanValue('my-new-feature', false)){
    //...
}

// You can add handlers to know what happen in the provider
client.addHandler(ProviderEvents.Ready, () => { ... });
client.addHandler(ProviderEvents.Error, () => { //... });
client.addHandler(ProviderEvents.Stale, () => { //... });
client.addHandler(ProviderEvents.ConfigurationChanged, () => { //... });

Available options

| Option name | Type | Default | Description | |-------------------------------|--------|----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | endpoint | string | | endpoint is the URL where your GO Feature Flag server is located. | | apiTimeout | number | 0 = no timeout | (optional) timeout is the time in millisecond we wait for an answer from the server. | | apiKey | string | | (optional) If GO Feature Flag is configured to authenticate the requests, you should provide an API Key to the provider. Please ask the administrator of the relay proxy to provide an API Key. | | websocketRetryInitialDelay | number | 100 | (optional) initial delay in millisecond to wait before retrying to connect the websocket | | websocketRetryDelayMultiplier | number | 2 | (optional) multiplier of websocketRetryInitialDelay after each failure (example: 1st connection retry will be after 100ms, second after 200ms, third after 400ms ...) | | websocketMaxRetries | number | 10 | (optional) maximum number of retries before considering the websocket unreachable |

Reconnection

If the connection to the GO Feature Flag instance fails, the provider will attempt to reconnect with an exponential back-off.
The websocketMaxRetries can be specified to customize reconnect behavior.

Event streaming

The GoFeatureFlagWebProvider receives events from GO Feature Flag with changes. Combined with the event API in the web SDK, this allows for subscription to flag value changes in clients.

client.addHandler(ProviderEvents.ConfigurationChanged, (ctx: EventDetails) => {
  // do something when the configuration has changed.
  // ctx.flagsChanged contains the list of changed flags.
});

Contribute

Building

Run nx package providers-go-feature-flag-web to build the library.

Running unit tests

Run nx test providers-go-feature-flag-web to execute the unit tests via Jest.