Skip to content

Commit 9be68fc

Browse files
chore: update sdk readmes
Signed-off-by: OpenFeature Bot <[email protected]>
1 parent 724f6c7 commit 9be68fc

File tree

14 files changed

+194
-38
lines changed

14 files changed

+194
-38
lines changed

docs/reference/technologies/client/kotlin.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This content has been automatically generated from kotlin-sdk.
1010
Edits should be made here: https://github.com/open-feature/kotlin-sdk
1111
Once a repo has been updated, docs can be generated by running: yarn update:sdk-docs
1212

13-
Last updated at Mon Nov 18 2024 08:10:25 GMT+0000 (Coordinated Universal Time)
13+
Last updated at Mon Dec 02 2024 08:10:31 GMT+0000 (Coordinated Universal Time)
1414
-->
1515

1616
<p align="center" class="github-badges">

docs/reference/technologies/client/swift.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This content has been automatically generated from swift-sdk.
1010
Edits should be made here: https://github.com/open-feature/swift-sdk
1111
Once a repo has been updated, docs can be generated by running: yarn update:sdk-docs
1212

13-
Last updated at Mon Nov 18 2024 08:10:25 GMT+0000 (Coordinated Universal Time)
13+
Last updated at Mon Dec 02 2024 08:10:31 GMT+0000 (Coordinated Universal Time)
1414
-->
1515

1616
<p align="center" class="github-badges">

docs/reference/technologies/client/web/angular.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ This content has been automatically generated from js-sdk.
1010
Edits should be made here: https://github.com/open-feature/js-sdk
1111
Once a repo has been updated, docs can be generated by running: yarn update:sdk-docs
1212

13-
Last updated at Mon Nov 18 2024 08:10:26 GMT+0000 (Coordinated Universal Time)
13+
Last updated at Mon Dec 02 2024 08:10:31 GMT+0000 (Coordinated Universal Time)
1414
-->
1515

1616
<p align="center" class="github-badges">
1717
<a href="https://github.com/open-feature/spec/releases/tag/v0.8.0">
1818
<img alt="Specification" src="https://img.shields.io/static/v1?label=specification&message=v0.8.0&color=yellow&style=for-the-badge" />
1919
</a>
2020

21-
<a href="https://github.com/open-feature/js-sdk/releases/tag/angular-sdk-v0.0.6-experimental">
22-
<img alt="Release" src="https://img.shields.io/static/v1?label=release&message=v0.0.6-experimental&color=blue&style=for-the-badge" />
21+
<a href="https://github.com/open-feature/js-sdk/releases/tag/angular-sdk-v0.0.9-experimental">
22+
<img alt="Release" src="https://img.shields.io/static/v1?label=release&message=v0.0.9-experimental&color=blue&style=for-the-badge" />
2323
</a>
2424

2525
<br/>

docs/reference/technologies/client/web/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This content has been automatically generated from js-sdk.
1010
Edits should be made here: https://github.com/open-feature/js-sdk
1111
Once a repo has been updated, docs can be generated by running: yarn update:sdk-docs
1212

13-
Last updated at Mon Nov 18 2024 08:10:25 GMT+0000 (Coordinated Universal Time)
13+
Last updated at Mon Dec 02 2024 08:10:30 GMT+0000 (Coordinated Universal Time)
1414
-->
1515

1616
<p align="center" class="github-badges">

docs/reference/technologies/client/web/react.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This content has been automatically generated from js-sdk.
1010
Edits should be made here: https://github.com/open-feature/js-sdk
1111
Once a repo has been updated, docs can be generated by running: yarn update:sdk-docs
1212

13-
Last updated at Mon Nov 18 2024 08:10:25 GMT+0000 (Coordinated Universal Time)
13+
Last updated at Mon Dec 02 2024 08:10:30 GMT+0000 (Coordinated Universal Time)
1414
-->
1515

1616
<p align="center" class="github-badges">

docs/reference/technologies/server/dotnet.mdx

Lines changed: 79 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ This content has been automatically generated from dotnet-sdk.
1010
Edits should be made here: https://github.com/open-feature/dotnet-sdk
1111
Once a repo has been updated, docs can be generated by running: yarn update:sdk-docs
1212

13-
Last updated at Mon Nov 18 2024 08:10:25 GMT+0000 (Coordinated Universal Time)
13+
Last updated at Mon Dec 02 2024 08:10:30 GMT+0000 (Coordinated Universal Time)
1414
-->
1515

1616
[![Specification](https://img.shields.io/static/v1?label=specification&message=v0.7.0&color=yellow&style=for-the-badge)](https://github.com/open-feature/spec/releases/tag/v0.7.0)
1717
[
18-
![Release](https://img.shields.io/static/v1?label=release&message=v2.0.0&color=blue&style=for-the-badge)
19-
](https://github.com/open-feature/dotnet-sdk/releases/tag/v2.0.0)
18+
![Release](https://img.shields.io/static/v1?label=release&message=v2.1.0&color=blue&style=for-the-badge)
19+
](https://github.com/open-feature/dotnet-sdk/releases/tag/v2.1.0)
2020

2121
[![Slack](https://img.shields.io/badge/slack-%40cncf%2Fopenfeature-brightgreen?style=flat&logo=slack)](https://cloud-native.slack.com/archives/C0344AANLA1)
2222
[![Codecov](https://codecov.io/gh/open-feature/dotnet-sdk/branch/main/graph/badge.svg?token=MONAVJBXUJ)](https://codecov.io/gh/open-feature/dotnet-sdk)
@@ -80,8 +80,9 @@ public async Task Example()
8080
| | [Eventing](#eventing) | React to state changes in the provider or flag management system. |
8181
| | [Shutdown](#shutdown) | Gracefully clean up a provider during application shutdown. |
8282
| | [Extending](#extending) | Extend OpenFeature with custom providers and hooks. |
83+
| 🔬 | [DependencyInjection](#DependencyInjection) | Integrate OpenFeature with .NET's dependency injection for streamlined provider setup. |
8384

84-
> Implemented: ✅ | In-progress: ⚠️ | Not implemented yet: ❌
85+
> Implemented: ✅ | In-progress: ⚠️ | Not implemented yet: ❌ | Experimental: 🔬
8586

8687
### Providers
8788

@@ -301,3 +302,77 @@ public class MyHook : Hook
301302

302303
Built a new hook? [Let us know](https://github.com/open-feature/openfeature.dev/issues/new?assignees=&labels=hook&projects=&template=document-hook.yaml&title=%5BHook%5D%3A+) so we can add it to the docs!
303304

305+
### DependencyInjection
306+
> [!NOTE]
307+
> The OpenFeature.DependencyInjection and OpenFeature.Hosting packages are currently experimental. They streamline the integration of OpenFeature within .NET applications, allowing for seamless configuration and lifecycle management of feature flag providers using dependency injection and hosting services.
308+
309+
#### Installation
310+
To set up dependency injection and hosting capabilities for OpenFeature, install the following packages:
311+
```sh
312+
dotnet add package OpenFeature.DependencyInjection
313+
dotnet add package OpenFeature.Hosting
314+
```
315+
#### Usage Examples
316+
For a basic configuration, you can use the InMemoryProvider. This provider is simple and well-suited for development and testing purposes.
317+
318+
**Basic Configuration:**
319+
```csharp
320+
builder.Services.AddOpenFeature(featureBuilder => {
321+
featureBuilder
322+
.AddHostedFeatureLifecycle() // From Hosting package
323+
.AddContext((contextBuilder, serviceProvider) => { /* Custom context configuration */ })
324+
.AddInMemoryProvider();
325+
});
326+
```
327+
**Domain-Scoped Provider Configuration:**
328+
<br />To set up multiple providers with a selection policy, define logic for choosing the default provider. This example designates `name1` as the default provider:
329+
```csharp
330+
builder.Services.AddOpenFeature(featureBuilder => {
331+
featureBuilder
332+
.AddHostedFeatureLifecycle()
333+
.AddContext((contextBuilder, serviceProvider) => { /* Custom context configuration */ })
334+
.AddInMemoryProvider("name1")
335+
.AddInMemoryProvider("name2")
336+
.AddPolicyName(options => {
337+
// Custom logic to select a default provider
338+
options.DefaultNameSelector = serviceProvider => "name1";
339+
});
340+
});
341+
```
342+
#### Creating a New Provider
343+
To integrate a custom provider, such as InMemoryProvider, you’ll need to create a factory that builds and configures the provider. This section demonstrates how to set up InMemoryProvider as a new provider with custom configuration options.
344+
345+
**Configuring InMemoryProvider as a New Provider**
346+
<br />Begin by creating a custom factory class, `InMemoryProviderFactory`, that implements `IFeatureProviderFactory`. This factory will initialize your provider with any necessary configurations.
347+
```csharp
348+
public class InMemoryProviderFactory : IFeatureProviderFactory
349+
{
350+
internal IDictionary<string, Flag>? Flags { get; set; }
351+
352+
public FeatureProvider Create() => new InMemoryProvider(Flags);
353+
}
354+
```
355+
**Adding an Extension Method to OpenFeatureBuilder**
356+
<br />To streamline the configuration process, add an extension method, `AddInMemoryProvider`, to `OpenFeatureBuilder`. This allows you to set up the provider with either a domain-scoped or a default configuration.
357+
358+
```csharp
359+
public static partial class FeatureBuilderExtensions
360+
{
361+
public static OpenFeatureBuilder AddInMemoryProvider(this OpenFeatureBuilder builder, Action<IDictionary<string, Flag>>? configure = null)
362+
=> builder.AddProvider<InMemoryProviderFactory>(factory => ConfigureFlags(factory, configure));
363+
364+
public static OpenFeatureBuilder AddInMemoryProvider(this OpenFeatureBuilder builder, string domain, Action<IDictionary<string, Flag>>? configure = null)
365+
=> builder.AddProvider<InMemoryProviderFactory>(domain, factory => ConfigureFlags(factory, configure));
366+
367+
private static void ConfigureFlags(InMemoryProviderFactory factory, Action<IDictionary<string, Flag>>? configure)
368+
{
369+
if (configure == null)
370+
return;
371+
372+
var flag = new Dictionary<string, Flag>();
373+
configure.Invoke(flag);
374+
factory.Flags = flag;
375+
}
376+
}
377+
```
378+

docs/reference/technologies/server/go.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This content has been automatically generated from go-sdk.
99
Edits should be made here: https://github.com/open-feature/go-sdk
1010
Once a repo has been updated, docs can be generated by running: yarn update:sdk-docs
1111

12-
Last updated at Mon Nov 18 2024 08:10:25 GMT+0000 (Coordinated Universal Time)
12+
Last updated at Mon Dec 02 2024 08:10:30 GMT+0000 (Coordinated Universal Time)
1313
-->
1414

1515
<p align="center" class="github-badges">

docs/reference/technologies/server/java.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This content has been automatically generated from java-sdk.
99
Edits should be made here: https://github.com/open-feature/java-sdk
1010
Once a repo has been updated, docs can be generated by running: yarn update:sdk-docs
1111

12-
Last updated at Mon Nov 18 2024 08:10:24 GMT+0000 (Coordinated Universal Time)
12+
Last updated at Mon Dec 02 2024 08:10:30 GMT+0000 (Coordinated Universal Time)
1313
-->
1414

1515
<p align="center" class="github-badges">

docs/reference/technologies/server/javascript/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This content has been automatically generated from js-sdk.
1010
Edits should be made here: https://github.com/open-feature/js-sdk
1111
Once a repo has been updated, docs can be generated by running: yarn update:sdk-docs
1212

13-
Last updated at Mon Nov 18 2024 08:10:24 GMT+0000 (Coordinated Universal Time)
13+
Last updated at Mon Dec 02 2024 08:10:30 GMT+0000 (Coordinated Universal Time)
1414
-->
1515

1616
<p align="center" class="github-badges">

docs/reference/technologies/server/javascript/nestjs.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This content has been automatically generated from js-sdk.
1010
Edits should be made here: https://github.com/open-feature/js-sdk
1111
Once a repo has been updated, docs can be generated by running: yarn update:sdk-docs
1212

13-
Last updated at Mon Nov 18 2024 08:10:25 GMT+0000 (Coordinated Universal Time)
13+
Last updated at Mon Dec 02 2024 08:10:30 GMT+0000 (Coordinated Universal Time)
1414
-->
1515

1616
<p align="center" class="github-badges">

0 commit comments

Comments
 (0)