-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from arkahna/feature/fb-102-nuget
Feature/fb 102 nuget
- Loading branch information
Showing
8 changed files
with
86 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'dotnet-sdk': patch | ||
--- | ||
|
||
Publish FeatureBoard dotnet-sdk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,129 +1,24 @@ | ||
## DotNet SDK | ||
|
||
## Installation | ||
## What is FeatureBoard? | ||
|
||
```powershell | ||
dotnet add package FeatureBoard.DotnetSdk | ||
``` | ||
|
||
|
||
## Setup | ||
|
||
1) Create a Features model | ||
Note that FeatureKeyName can be used here to apply the correct feature key to a property, otherwise feature board will do it's best to convert the property to a kebab case key. | ||
```csharp | ||
using FeatureBoard.DotnetSdk.Models; | ||
|
||
public class WeatherFeatures : IFeatures | ||
{ | ||
[FeatureKeyName("weather-imperial")] | ||
public bool WeatherImperial { get; set; } | ||
} | ||
``` | ||
|
||
2) Implement the audiance provider. | ||
This should provide the audiance of the current user or application context and could pull from the users token or app settings etc. | ||
```csharp | ||
using FeatureBoard.DotnetSdk; | ||
|
||
public class ClaimsAudienceProvider : IAudienceProvider | ||
{ | ||
public List<string> AudienceKeys { get; } | ||
|
||
public ClaimsAudienceProvider(IHttpContextAccessor contextAccessor) | ||
{ | ||
AudienceKeys = contextAccessor.HttpContext?.User.Claims | ||
.Where(x => x.Type == "audience") | ||
.Select(x => x.Value).ToList() ?? new List<string>(); | ||
} | ||
} | ||
``` | ||
|
||
|
||
3) Register the provider in `program.cs` | ||
```csharp | ||
// Register feature board | ||
builder.Services.AddFeatureBoard<WeatherFeatures, ClaimsAudienceProvider>() | ||
.WithPollingUpdateStrategy(); | ||
``` | ||
FeatureBoard is the future of Feature Toggling and is tailored for SaaS teams on the hunt for a simplified yet highly potent feature toggling solution. FeatureBoard enhances team productivity by allowing everyone to manage software features seamlessly, not just developers. | ||
|
||
4) Add any required middleware | ||
```csharp | ||
// Add feature board middleware | ||
app.UseFeatureBoard(); | ||
``` | ||
|
||
5) Add the enviroment key to your appsettings.json file | ||
```json | ||
{ | ||
.... | ||
"AllowedHosts": "*", | ||
"FeatureBoardOptions": { | ||
"EnvironmentApiKey": "YOUR KEY HERE" | ||
} | ||
} | ||
``` | ||
|
||
|
||
|
||
## Usage | ||
```csharp | ||
using FeatureBoard.DotnetSdk; | ||
using FeatureBoardSdks.Examples.DotnetApi.Models; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace FeatureBoardSdks.Examples.DotnetApi.Controllers; | ||
|
||
[ApiController] | ||
[Route("[controller]")] | ||
public class WeatherForecastController : ControllerBase | ||
{ | ||
## How do I get started? | ||
|
||
private readonly IFeatureBoardClient<WeatherFeatures> _featureBoardClient; | ||
To get started checkout our [getting started guide](https://docs.featureboard.app). | ||
|
||
public WeatherForecastController(ILogger<WeatherForecastController> logger, IFeatureBoardClient<WeatherFeatures> featureBoardClient) | ||
{ | ||
_featureBoardClient = featureBoardClient; | ||
} | ||
## Install FeatureBoard .Net SDK | ||
|
||
[HttpGet(Name = "GetWeatherForecast")] | ||
public async Task<ActionResult<WeatherForecast[]>> Get() | ||
{ | ||
if (_featureBoardClient.GetFeatureValue(features => features.WeatherImperial, false)) | ||
{ | ||
// Return Fahrenheit | ||
} | ||
else | ||
{ | ||
// Return Celsius | ||
} | ||
} | ||
} | ||
FeatureBoard .Net SDK is installed from NuGet. | ||
|
||
```powershell | ||
dotnet add package FeatureBoard.DotnetSdk | ||
``` | ||
|
||
## Setup and example | ||
|
||
## External State Store | ||
You can create an external state to provide state in case that feature board is unavilable by implementing `IFeatureBoardExternalState` | ||
How to setup and use FeatureBoard .Net SDK can be found in our [documentation](https://docs.featureboard.app/sdks/dotnet-sdk/). | ||
|
||
```csharp | ||
using FeatureBoard.DotnetSdk.Models; | ||
using FeatureBoard.DotnetSdk.States; | ||
## Release notes | ||
|
||
public class MyExternalState: IFeatureBoardExternalState | ||
{ | ||
public Task<Dictionary<string, FeatureConfiguration>> GetState(CancellationToken cancellationToken) | ||
{....} | ||
|
||
public Task UpdateState(Dictionary<string, FeatureConfiguration>? features, CancellationToken cancellationToken) | ||
{....} | ||
} | ||
``` | ||
|
||
And registering it in `program.cs` | ||
|
||
```csharp | ||
builder.Services.AddFeatureBoard<WeatherFeatures, QueryStringAudienceProvider>() | ||
.WithPollingUpdateStrategy() | ||
.WithExternalState<MyExternalState>(); | ||
``` | ||
Our changelog [can be found on GitHub](https://github.com/arkahna/featureboard-sdks/blob/main/libs/dotnet-sdk/CHANGELOG.md). |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"name": "dontnet-sdk", | ||
"version": "1.0.0", | ||
"name": "dotnet-sdk", | ||
"version": "0.0.1", | ||
"private": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters