From 346026a8c12336ae0b0217796a962a09187519ed Mon Sep 17 00:00:00 2001 From: Thomas Poignant Date: Wed, 14 Aug 2024 22:25:49 +0200 Subject: [PATCH] rebuild doc v1.32.0 Signed-off-by: Thomas Poignant --- .../configure_flag/rule_format.md | 7 +- .../getting_started/using-openfeature.md | 11 +- .../client_providers/openfeature_android.mdx | 35 +++++ .../openfeature_javascript.mdx | 24 ++++ .../client_providers/openfeature_swift.mdx | 25 ++++ .../version-v1.32.0/openfeature_sdk/sdk.mdx | 9 ++ .../server_providers/openfeature_dotnet.mdx | 2 +- .../server_providers/openfeature_go.mdx | 23 +--- .../openfeature_javascript.mdx | 2 +- .../server_providers/openfeature_ruby.md | 129 ++++++++++++++++++ website/versions.json | 11 +- 11 files changed, 245 insertions(+), 33 deletions(-) create mode 100644 website/versioned_docs/version-v1.32.0/openfeature_sdk/server_providers/openfeature_ruby.md diff --git a/website/versioned_docs/version-v1.32.0/configure_flag/rule_format.md b/website/versioned_docs/version-v1.32.0/configure_flag/rule_format.md index 9914856bbd5..0126a04fd65 100644 --- a/website/versioned_docs/version-v1.32.0/configure_flag/rule_format.md +++ b/website/versioned_docs/version-v1.32.0/configure_flag/rule_format.md @@ -25,9 +25,10 @@ The targeting key is a fundamental part of the evaluation context because it dir When you create an evaluation context some fields are reserved for GO Feature Flag. Those fields are used by GO Feature Flag directly, you can use them as will but you should be aware that they are used by GO Feature Flag. -| Field | Description | -|---------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `gofeatureflag.currentDateTime` | If this property is set, we will use this date as base for all the rollout strategies which implies dates _(experimentation, progressive and scheduled)_.
**Format:** Date following the RF3339 format. | +| Field | Description | +|---------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `gofeatureflag.currentDateTime` | If this property is set, we will use this date as base for all the rollout strategies which implies dates _(experimentation, progressive and scheduled)_.
**Format:** Date following the RF3339 format. | +| `gofeatureflag.flagList` | If this property is set, in the bulk evaluation mode (for the client SDK) we will only evaluate the flags in this list.
If empty or not set the default behavior is too evaluate all the flags.
**Format:** []string | ## Rule format diff --git a/website/versioned_docs/version-v1.32.0/getting_started/using-openfeature.md b/website/versioned_docs/version-v1.32.0/getting_started/using-openfeature.md index 06fb69266f4..ff6bc6b3ac0 100644 --- a/website/versioned_docs/version-v1.32.0/getting_started/using-openfeature.md +++ b/website/versioned_docs/version-v1.32.0/getting_started/using-openfeature.md @@ -9,14 +9,15 @@ OpenFeature provides a shared, standardized feature flagging client - _an SDK_ - Whether you're using an open-source system or a commercial product, whether it's self-hosted or cloud-hosted, OpenFeature provides a consistent, unified API for developers to use feature flagging in their applications. _[Documentation](https://docs.openfeature.dev)_ ::: +GO Feature Flag is committed to **opensource** principles and **standardization**. To achieve this, we've chosen to rely solely on [OpenFeature](https://docs.openfeature.dev) and avoid building custom SDKs. -GO Feature Flag believes in **Open-Source** and **standardization**, this is the reason why we have decided not implementing any custom SDK and rely only on **Open Feature**. +To seamlessly integrate with OpenFeature, we provide a lightweight, self-hosted API server called the **relay proxy**. This proxy leverages the core GO Feature Flag module internally. By deploying the relay proxy in your infrastructure, you can utilize Open Feature SDKs in conjunction with GO Feature Flag providers to evaluate your feature flags. -To be compatible with Open Feature, **GO Feature Flag** is providing a lightweight self-hosted API server *(called [relay proxy](../relay_proxy))* that is using the GO Feature Flag module internally. -When the **relay proxy** is running in your infrastructure, you can use the **Open Feature SDKs** in combination with **GO Feature Flag providers** to evaluate your flags. +For a comprehensive understanding of how Open Feature operates, please refer to the official **[Open Feature documentation](https://docs.openfeature.dev)**.tps://docs.openfeature.dev)**. -This schema is an overview on how **Open Feature** is working, you can have more information about all the concepts in the **[Open Feature documentation](https://docs.openfeature.dev)**. -![](/docs/openfeature/concepts.png) +## Integration pattern + + ## Create a feature flag configuration diff --git a/website/versioned_docs/version-v1.32.0/openfeature_sdk/client_providers/openfeature_android.mdx b/website/versioned_docs/version-v1.32.0/openfeature_sdk/client_providers/openfeature_android.mdx index 221cc1e5a61..146bbfb61a2 100644 --- a/website/versioned_docs/version-v1.32.0/openfeature_sdk/client_providers/openfeature_android.mdx +++ b/website/versioned_docs/version-v1.32.0/openfeature_sdk/client_providers/openfeature_android.mdx @@ -109,6 +109,41 @@ OpenFeatureAPI.setEvaluationContext(newEvalCtx) `setEvaluationContext()` is a synchronous function similar to `setProvider()` and will fetch the new version of the feature flags based on this new `EvaluationContext`. +### Limit the flags to evaluate + +By default, the provider will fetch all the flags configured in the GO Feature Flag server to be ready to evaluate them. +If you know in advance, what are the flags you will evaluate in your application, you can specify the list of flags to evaluate in the context. + +You need to add in the evaluation context the restricted key `gofeatureflag.flagList` with the list of flags you want to evaluate. + +```kotlin +val newContext: EvaluationContext = ImmutableContext( + targetingKey = "userId", + attributes = mapOf( + "gofeatureflag" to Value.Structure( + mapOf( + "flagList" to Value.List( + listOf( + // list of flags to evaluate + Value.String("flag1"), + Value.String("flag2"), + Value.String("flag3") + ) + ), + ) + ), + ) + ) + +OpenFeatureAPI.setEvaluationContext(newEvalCtx) +``` + +By setting the `gofeatureflag.flagList` key in the context, the provider will only fetch the flags specified in the list. + +:::warning +When limiting the flags to evaluate, if you try to evaluate a flag not in the list, the provider will return the default value with the error `FLAG_NOT_FOUND`. +::: + ### Evaluate a feature flag The client is used to retrieve values for the current `EvaluationContext`. For example, retrieving a boolean value for the flag **"my-flag"**: diff --git a/website/versioned_docs/version-v1.32.0/openfeature_sdk/client_providers/openfeature_javascript.mdx b/website/versioned_docs/version-v1.32.0/openfeature_sdk/client_providers/openfeature_javascript.mdx index e4231e50f24..f3d899ce3a1 100644 --- a/website/versioned_docs/version-v1.32.0/openfeature_sdk/client_providers/openfeature_javascript.mdx +++ b/website/versioned_docs/version-v1.32.0/openfeature_sdk/client_providers/openfeature_javascript.mdx @@ -56,6 +56,30 @@ client.addHandler(ProviderEvents.Stale, () => { //... }); client.addHandler(ProviderEvents.ConfigurationChanged, () => { //... }); ``` +### Limit the flags to evaluate + +By default, the provider will fetch all the flags configured in the GO Feature Flag server to be ready to evaluate them. +If you know in advance, what are the flags you will evaluate in your application, you can specify the list of flags to evaluate in the context. + +You need to add in the evaluation context the restricted key `gofeatureflag.flagList` with the list of flags you want to evaluate. + +```typescript +OpenFeature.setContext({ + // ... + gofeatureflag: { + flagList: ['flag1', 'flag2'] + } +}); + +await OpenFeature.setContext(evaluationCtx); +``` + +By setting the `gofeatureflag.flagList` key in the context, the provider will only fetch the flags specified in the list. + +:::warning +When limiting the flags to evaluate, if you try to evaluate a flag not in the list, the provider will return the default value with the error `FLAG_NOT_FOUND`. +::: + ### Available options | Option name | Type | Default | Description | |-------------------------------|--------|----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| diff --git a/website/versioned_docs/version-v1.32.0/openfeature_sdk/client_providers/openfeature_swift.mdx b/website/versioned_docs/version-v1.32.0/openfeature_sdk/client_providers/openfeature_swift.mdx index d9faf8e1423..d9579030396 100644 --- a/website/versioned_docs/version-v1.32.0/openfeature_sdk/client_providers/openfeature_swift.mdx +++ b/website/versioned_docs/version-v1.32.0/openfeature_sdk/client_providers/openfeature_swift.mdx @@ -89,6 +89,31 @@ OpenFeatureAPI.shared.setEvaluationContext(evaluationContext: ctx) `setEvaluationContext()` is a synchronous function similar to `setProvider()` and will fetch the new version of the feature flags based on this new `EvaluationContext`. +### Limit the flags to evaluate + +By default, the provider will fetch all the flags configured in the GO Feature Flag server to be ready to evaluate them. +If you know in advance, what are the flags you will evaluate in your application, you can specify the list of flags to evaluate in the context. + +You need to add in the evaluation context the restricted key `gofeatureflag.flagList` with the list of flags you want to evaluate. + +```swift +let ctx = MutableContext(targetingKey: "myNewTargetingKey") +ctx.add( + key: "gofeatureflag", + value: Value.list([ + Value.string("flag1"), + Value.string("flag2") + ]) +) +OpenFeatureAPI.shared.setEvaluationContext(evaluationContext: ctx) +``` + +By setting the `gofeatureflag.flagList` key in the context, the provider will only fetch the flags specified in the list. + +:::warning +When limiting the flags to evaluate, if you try to evaluate a flag not in the list, the provider will return the default value with the error `FLAG_NOT_FOUND`. +::: + ### Evaluate a feature flag The client is used to retrieve values for the current `EvaluationContext`. For example, retrieving a boolean value for the flag **"my-flag"**: diff --git a/website/versioned_docs/version-v1.32.0/openfeature_sdk/sdk.mdx b/website/versioned_docs/version-v1.32.0/openfeature_sdk/sdk.mdx index 976643588f6..984bfd90204 100644 --- a/website/versioned_docs/version-v1.32.0/openfeature_sdk/sdk.mdx +++ b/website/versioned_docs/version-v1.32.0/openfeature_sdk/sdk.mdx @@ -62,6 +62,15 @@ Rest assured, working with OpenFeature SDKs alongside GO Feature Flag providers content: + }, + { + logoCss: "devicon-ruby-plain colored", + title:"Ruby", + badges:["Server"], + docLink: "./server_providers/openfeature_ruby", + content: } ]}/> diff --git a/website/versioned_docs/version-v1.32.0/openfeature_sdk/server_providers/openfeature_dotnet.mdx b/website/versioned_docs/version-v1.32.0/openfeature_sdk/server_providers/openfeature_dotnet.mdx index 4692bd2ff0c..b82697f0d3e 100644 --- a/website/versioned_docs/version-v1.32.0/openfeature_sdk/server_providers/openfeature_dotnet.mdx +++ b/website/versioned_docs/version-v1.32.0/openfeature_sdk/server_providers/openfeature_dotnet.mdx @@ -1,5 +1,5 @@ --- -sidebar_position: 52 +sidebar_position: 60 title: .NET description: How to use the OpenFeature .Net SDK --- diff --git a/website/versioned_docs/version-v1.32.0/openfeature_sdk/server_providers/openfeature_go.mdx b/website/versioned_docs/version-v1.32.0/openfeature_sdk/server_providers/openfeature_go.mdx index 01c04884386..1d9f03724e6 100644 --- a/website/versioned_docs/version-v1.32.0/openfeature_sdk/server_providers/openfeature_go.mdx +++ b/website/versioned_docs/version-v1.32.0/openfeature_sdk/server_providers/openfeature_go.mdx @@ -39,27 +39,6 @@ options := gofeatureflag.ProviderOptions{ provider, _ := gofeatureflag.NewProvider(options) ``` -### Using the GO module _(standalone version)_ -If you want to use the provider in standalone mode using the GO module, you should set the field `GOFeatureFlagConfig` -in the options. - -You can check the [GO Feature Flag documentation website](https://docs.gofeatureflag.org) to look how to configure the -GO module. - -#### Example -```go -options := gofeatureflag.ProviderOptions{ - GOFeatureFlagConfig: &ffclient.Config{ - PollingInterval: 10 * time.Second, - Context: context.Background(), - Retriever: &fileretriever.Retriever{ - Path: "../testutils/module/flags.yaml", - }, - }, -} -provider, _ := gofeatureflag.NewProvider(options) -``` - ## Initialize your Open Feature client To evaluate the flags you need to have an Open Feature configured in you app. @@ -84,7 +63,7 @@ client := of.NewClient("my-app") ## Evaluate your flag -This code block explain how you can create an `EvaluationContext` and use it to evaluate your flag. +This code block explains how you can create an `EvaluationContext` and use it to evaluate your flag. > In this example we are evaluating a `boolean` flag, but other types are also available. diff --git a/website/versioned_docs/version-v1.32.0/openfeature_sdk/server_providers/openfeature_javascript.mdx b/website/versioned_docs/version-v1.32.0/openfeature_sdk/server_providers/openfeature_javascript.mdx index 058c33c526b..61aa56c1947 100644 --- a/website/versioned_docs/version-v1.32.0/openfeature_sdk/server_providers/openfeature_javascript.mdx +++ b/website/versioned_docs/version-v1.32.0/openfeature_sdk/server_providers/openfeature_javascript.mdx @@ -1,5 +1,5 @@ --- -sidebar_position: 51 +sidebar_position: 41 title: Node.js description: How to use the OpenFeature Javascript SDK --- diff --git a/website/versioned_docs/version-v1.32.0/openfeature_sdk/server_providers/openfeature_ruby.md b/website/versioned_docs/version-v1.32.0/openfeature_sdk/server_providers/openfeature_ruby.md new file mode 100644 index 00000000000..06dda6dbc86 --- /dev/null +++ b/website/versioned_docs/version-v1.32.0/openfeature_sdk/server_providers/openfeature_ruby.md @@ -0,0 +1,129 @@ +--- +sidebar_position: 52 +title: Ruby +description: How to use the OpenFeature Ruby SDK with GO Feature Flag +--- + +# Ruby provider + gem + +This repository contains the official Ruby OpenFeature provider for accessing your feature flags with [GO Feature Flag](https://gofeatureflag.org). + +In conjuction with the [OpenFeature SDK](https://openfeature.dev/docs/reference/concepts/provider) you will be able +to evaluate your feature flags in your Ruby applications. + +For documentation related to flags management in GO Feature Flag, +refer to the [GO Feature Flag documentation website](https://gofeatureflag.org/docs). + +### Functionalities: +- Manage the integration of the OpenFeature Ruby SDK and GO Feature Flag relay-proxy. + +## Dependency Setup + +### Gem Package Manager + +Add this line to your application's Gemfile: +``` +gem 'openfeature-go-feature-flag-provider' +``` +And then execute: +``` +bundle install +``` +Or install it yourself as: +``` +gem install openfeature-go-feature-flag-provider +``` + +## Getting started + +### Initialize the provider + +The `OpenFeature::GoFeatureFlag::Provider` needs some options to be created and then set in the OpenFeature SDK. + +| **Option** | **Description** | +|------------|---------------------------------------------------------------------------------------------------------------------------------------------| +| `endpoint` | **(mandatory)** The URL to access to the relay-proxy.
*(example: `https://relay.proxy.gofeatureflag.org/`)* | +| `headers` | A `Hash` object containing the headers to send to the relay-proxy.
*(example to send APIKey: `{"Authorization" => "Bearer my-api-key"}` | + +The only required option to create a `GoFeatureFlagProvider` is the URL _(`endpoint`)_ to your GO Feature Flag relay-proxy instance. + +```ruby +import GOFeatureFlag +import OpenFeature + +# ... + +options = OpenFeature::GoFeatureFlag::Options.new(endpoint: "http://localhost:1031") +provider = OpenFeature::GoFeatureFlag::Provider.new(options: options) + +evaluation_context = OpenFeature::SDK::EvaluationContext.new(targeting_key: "9b9450f8-ab5c-4dcf-872f-feda3f6ccb16") + +OpenFeature::SDK.configure do |config| + config.set_provider(provider) +end +client = OpenFeature::SDK.build_client() + +bool_value = client.fetch_boolean_value( + flag_key: "my-boolean-flag", + default_value: false, + evaluation_context: evaluation_context +) + +if bool_value + puts "The flag is enabled" +else + puts "The flag is disabled" +end +``` + +The evaluation context is the way for the client to specify contextual data that GO Feature Flag uses to evaluate the feature flags, it allows to define rules on the flag. + +The `targeting_key` is mandatory for GO Feature Flag to evaluate the feature flag, it could be the id of a user, a session ID or anything you find relevant to use as identifier during the evaluation. + + +### Evaluate a feature flag +The client is used to retrieve values for the current `EvaluationContext`. +For example, retrieving a boolean value for the flag **"my-flag"**: + +```ruby +client = OpenFeature::SDK.build_client() + +bool_value = client.fetch_boolean_value( + flag_key: "my-boolean-flag", + default_value: false, + evaluation_context: evaluation_context +) +``` + +GO Feature Flag supports different all OpenFeature supported types of feature flags, it means that you can use all the accessor directly +```ruby +# Bool +client.fetch_boolean_value(flag_key: 'my-flag', default_value: false, evaluation_context: evaluation_context) + +# String +client.fetch_string_value(flag_key: 'my-flag', default_value: "default", evaluation_context: evaluation_context) + +# Number +client.fetch_number_value(flag_key: 'my-flag', default_value: 0, evaluation_context: evaluation_context) + +# Object +client.fetch_object_value(flag_key: 'my-flag', default_value: {"default" => true}, evaluation_context: evaluation_context) +``` + +## Features status + +| Status | Feature | Description | +|--------|-----------------|----------------------------------------------------------------------------| +| ✅ | Flag evaluation | It is possible to evaluate all the type of flags | +| ❌ | Caching | Mechanism is in place to refresh the cache in case of configuration change | +| ❌ | Event Streaming | Not supported by the SDK | +| ❌ | Logging | Not supported by the SDK | +| ✅ | Flag Metadata | Not supported by the SDK | + + +**Implemented**: ✅ | In-progress: ⚠️ | Not implemented yet: ❌ + +## Contributing +This project welcomes contributions from the community. +If you're interested in contributing, see the [contributors' guide](https://github.com/thomaspoignant/go-feature-flag/blob/main/CONTRIBUTING.md) for some helpful tips. diff --git a/website/versions.json b/website/versions.json index d2a1cb44557..5a97fd0ece0 100644 --- a/website/versions.json +++ b/website/versions.json @@ -1 +1,10 @@ -["v1.32.0","v1.31.2","v1.31.1","v1.31.0","v1.30.0","v1.29.0","v1.28.2","v1.28.1"] \ No newline at end of file +[ + "v1.32.0", + "v1.31.2", + "v1.31.1", + "v1.31.0", + "v1.30.0", + "v1.29.0", + "v1.28.2", + "v1.28.1" +]