Skip to content

Commit

Permalink
rebuild doc v1.32.0
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Poignant <[email protected]>
  • Loading branch information
thomaspoignant committed Aug 14, 2024
1 parent 0bd08f7 commit 346026a
Show file tree
Hide file tree
Showing 11 changed files with 245 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)_.<br/>**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)_.<br/>**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.<br/>If empty or not set the default behavior is too evaluate all the flags.<br/>**Format:** []string |

## Rule format

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

<img src="/docs/openfeature/concepts.png" style={{borderRadius: "1.4em"}} />

## Create a feature flag configuration

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"**:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
|-------------------------------|--------|----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"**:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ Rest assured, working with OpenFeature SDKs alongside GO Feature Flag providers
content: <SdkCardContent
badgeUrl={"https://img.shields.io/pypi/v/gofeatureflag-python-provider?color=blue&style=flat-square&logo=pypi"}
features={["remoteEval", "localCache", "dynamicRefresh"]}/>
},
{
logoCss: "devicon-ruby-plain colored",
title:"Ruby",
badges:["Server"],
docLink: "./server_providers/openfeature_ruby",
content: <SdkCardContent
badgeUrl={"https://img.shields.io/gem/v/openfeature-go-feature-flag-provider?color=blue&style=flat-square&logo=ruby"}
features={["remoteEval"]}/>
}
]}/>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 52
sidebar_position: 60
title: .NET
description: How to use the OpenFeature .Net SDK
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 51
sidebar_position: 41
title: Node.js
description: How to use the OpenFeature Javascript SDK
---
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
---
sidebar_position: 52
title: Ruby
description: How to use the OpenFeature Ruby SDK with GO Feature Flag
---

# Ruby provider
<a href="https:/open-feature/ruby-sdk-contrib/tree/main/providers/openfeature-go-feature-flag-provider"><img src="https://img.shields.io/gem/v/openfeature-go-feature-flag-provider?color=blue&style=flat-square&logo=ruby" alt="gem" /></a>

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.<br />*(example: `https://relay.proxy.gofeatureflag.org/`)* |
| `headers` | A `Hash` object containing the headers to send to the relay-proxy.<br/>*(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 |


<sub>**Implemented**: ✅ | In-progress: ⚠️ | Not implemented yet: ❌</sub>

## Contributing
This project welcomes contributions from the community.
If you're interested in contributing, see the [contributors' guide](https:/thomaspoignant/go-feature-flag/blob/main/CONTRIBUTING.md) for some helpful tips.
11 changes: 10 additions & 1 deletion website/versions.json
Original file line number Diff line number Diff line change
@@ -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"]
[
"v1.32.0",
"v1.31.2",
"v1.31.1",
"v1.31.0",
"v1.30.0",
"v1.29.0",
"v1.28.2",
"v1.28.1"
]

0 comments on commit 346026a

Please sign in to comment.