Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add FeatureManagement documentation #197

Merged
Merged
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
3 changes: 2 additions & 1 deletion release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
"bump-patch-for-minor-pre-major": true,
"versioning": "default",
"extra-files": [
"OpenFeature.Contrib.Providers.FeatureManagement.csproj"
"OpenFeature.Contrib.Providers.FeatureManagement.csproj",
"README.md"
]
},
"src/OpenFeature.Contrib.Providers.Statsig": {
Expand Down
105 changes: 105 additions & 0 deletions src/OpenFeature.Contrib.Providers.FeatureManagement/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# FeatureManagement .NET Provider
> ![NOTE]
> This requires a new feature of the FeatureManagement system, Variants. This feature is still in preview and has not been fully released.

The FeatureManagement Provider allows you to use the FeatureManagement system as an OpenFeature Provider.

## .NET SDK Usage

### Install dependencies
<!--- {x-release-please-start-version} -->

#### .NET Cli

```shell
dotnet add package OpenFeature.Contrib.Provider.FeatureManagement --version 0.0.1-preview
ericpattison marked this conversation as resolved.
Show resolved Hide resolved
```

#### Package Manager

```shell
NuGet\Install-Package OpenFeature.Contrib.Provider.FeatureManagement -Version 0.0.1-preview
```

#### Package Reference

```xml
<PackageReference Include="OpenFeature.Contrib.Provider.FeatureManagement" Version="0.0.1-preview" />
```

#### Paket CLI
```shell
paket add OpenFeature.Contrib.Provider.FeatureManagement --version 0.0.1-preview
```

#### Cake

```shell
// Install OpenFeature.Contrib.Provider.FeatureManagement as a Cake Addin
#addin nuget:?package=OpenFeature.Contrib.Provider.FeatureManagement&version=0.0.1-preview&prerelease

// Install OpenFeature.Contrib.Provider.FeatureManagement as a Cake Tool
#tool nuget:?package=OpenFeature.Contrib.Provider.FeatureManagement&version=0.0.1-preview&prerelease
```
<!--- {x-release-please-end} -->

### Using the FeatureManagement Provider with the OpenFeature SDK

FeatureManagement is built on top of .NETs Configuration system, so you must provide the loaded Configuration.
Since Configuration is passed in any valid Configuration source can be used.
For simplicity, we'll stick with a json file for all examples.

```csharp
namespace OpenFeatureTestApp
{
class Program
{
static void Main(string[] args)
{
var configurationBuilder = new ConfigurationBuilder();
configurationBuilder.AddJsonFile("featureFlags.json");

IConfiguration configuration = configurationBuilder.Build();

var featureManagementProvider = new FeatureManagementProvider(configuration);
OpenFeature.Api.Instance.SetProvider(featureManagementProvider);

var client = OpenFeature.Api.Instance.GetClient();

var val = await client.GetBooleanValue("myBoolFlag", false, null);

System.Console.WriteLine(val.ToString());
}
}
}
```

A simple example configuration would look like this.

```json
{
"FeatureManagement": {
"myBoolFlag": {
"Allocation": {
"DefaultWhenEnabled": "FlagEnabled",
"DefaultWhenDisabled": "FlagDisabled"
},
"Variants": [
{
"Name": "FlagEnabled",
"ConfigurationValue": true
},
{
"Name": "FlagDisabled",
"ConfigurationValue": false
}
],
"EnabledFor": [
{
"Name": "AlwaysOn"
}
]
}
}
}
```
Loading