@arcanaio/go-feature-flag-web-provider-fixed

中文文档
0.2.8发布于 2025/10/01Apache-2.0TypeScriptESM + CJS近 30 天下载 3947

GO Feature Flag web provider for OpenFeature with websocket connection fixes

原始使用文档
文档目录10 节
  1. About this provider
  2. What is GO Feature Flag?
  3. Install the provider
  4. How to use the provider?
  5. Available options
  6. Reconnection
  7. Event streaming
  8. Contribute
  9. Building
  10. Running unit tests

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 nameTypeDefaultDescription
endpointstringendpoint is the URL where your GO Feature Flag server is located.
apiTimeoutnumber0 = no timeout(optional) timeout is the time in millisecond we wait for an answer from the server.
apiKeystring(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.
websocketRetryInitialDelaynumber100(optional) initial delay in millisecond to wait before retrying to connect the websocket
websocketRetryDelayMultipliernumber2(optional) multiplier of websocketRetryInitialDelay after each failure (example: 1st connection retry will be after 100ms, second after 200ms, third after 400ms ...)
websocketMaxRetriesnumber10(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.

版本与发布记录

@arcanaio/go-feature-flag-web-provider-fixed 共发布 2 个版本,首次发布于 2025/10/01;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.2.8latest2025/10/011.1 年前
0.2.72025/10/011.1 年前

关于 @arcanaio/go-feature-flag-web-provider-fixed 的常见问题

@arcanaio/go-feature-flag-web-provider-fixed 是什么?

GO Feature Flag web provider for OpenFeature with websocket connection fixes

如何安装 @arcanaio/go-feature-flag-web-provider-fixed?

在项目目录运行 npm install @arcanaio/go-feature-flag-web-provider-fixed,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@openfeature/web-sdk(^1.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@arcanaio/go-feature-flag-web-provider-fixed 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@arcanaio/go-feature-flag-web-provider-fixed 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@arcanaio/go-feature-flag-web-provider-fixed 可以商用吗?

@arcanaio/go-feature-flag-web-provider-fixed 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@arcanaio/go-feature-flag-web-provider-fixed 的下载量有多少?

根据 npm 官方下载统计,@arcanaio/go-feature-flag-web-provider-fixed 在 2026/10/07 – 2026/11/05 这 30 天内被下载 3,947 次,日均约 132 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@arcanaio/go-feature-flag-web-provider-fixed 还在维护吗?

最新版本 0.2.8 发布于 2025/10/01(1.1 年前);至今共发布 2 个版本,其中过去 12 个月发布了 0 个;首次发布于 2025/10/01。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。