Class Provider
An OpenFeature OpenFeature.FeatureProvider which enables the use of the LaunchDarkly Server-Side SDK for .NET with OpenFeature.
Inherited Members
Namespace: LaunchDarkly.OpenFeature.ServerProvider
Assembly: LaunchDarkly.OpenFeature.ServerProvider.dll
Syntax
public sealed class Provider : FeatureProvider
Examples
var provider = new Provider(Configuration.Builder("my-sdk-key").Build());
OpenFeature.Api.Instance.SetProvider(provider);
var client = OpenFeature.Api.Instance.GetClient();
Constructors
| Edit this page View SourceProvider(Configuration)
Construct a new instance of the provider with the given configuration.
Declaration
public Provider(Configuration config)
Parameters
Type | Name | Description |
---|---|---|
Configuration | config | A client configuration object |
Provider(string)
Construct a new instance of the provider with the given SDK key.
Declaration
public Provider(string sdkKey)
Parameters
Type | Name | Description |
---|---|---|
string | sdkKey | The SDK key |
Methods
| Edit this page View SourceGetClient()
Get the underlying client instance.
If the initialization/shutdown features of OpenFeature are being used, then the returned client instance may be shutdown if the provider has been removed from the OpenFeature API instance.
This client instance can be used to take advantage of features which are not part of OpenFeature. For instance using migration flags.
Declaration
public ILdClient GetClient()
Returns
Type | Description |
---|---|
ILdClient | The LaunchDarkly client instance |
GetMetadata()
Metadata describing the provider.
Declaration
public override Metadata GetMetadata()
Returns
Type | Description |
---|---|
Metadata | OpenFeature.Model.Metadata |
Overrides
InitializeAsync(EvaluationContext, CancellationToken)
This method is called before a provider is used to evaluate flags. Providers can overwrite this method, if they have special initialization needed prior being called for flag evaluation. When this method completes, the provider will be considered ready for use.
Declaration
public override Task InitializeAsync(EvaluationContext context, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
EvaluationContext | context | OpenFeature.Model.EvaluationContext |
CancellationToken | cancellationToken | The CancellationToken to cancel any async side effects. |
Returns
Type | Description |
---|---|
Task | A task that completes when the initialization process is complete. |
Overrides
Remarks
Providers not implementing this method will be considered ready immediately.
ResolveBooleanValueAsync(string, bool, EvaluationContext, CancellationToken)
Resolves a boolean feature flag
Declaration
public override Task<ResolutionDetails<bool>> ResolveBooleanValueAsync(string flagKey, bool defaultValue, EvaluationContext context = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | flagKey | Feature flag key |
bool | defaultValue | Default value |
EvaluationContext | context | OpenFeature.Model.EvaluationContext |
CancellationToken | cancellationToken | The CancellationToken. |
Returns
Type | Description |
---|---|
Task<ResolutionDetails<bool>> | OpenFeature.Model.ResolutionDetails<T> |
Overrides
| Edit this page View SourceResolveDoubleValueAsync(string, double, EvaluationContext, CancellationToken)
Resolves a double feature flag
Declaration
public override Task<ResolutionDetails<double>> ResolveDoubleValueAsync(string flagKey, double defaultValue, EvaluationContext context = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | flagKey | Feature flag key |
double | defaultValue | Default value |
EvaluationContext | context | OpenFeature.Model.EvaluationContext |
CancellationToken | cancellationToken | The CancellationToken. |
Returns
Type | Description |
---|---|
Task<ResolutionDetails<double>> | OpenFeature.Model.ResolutionDetails<T> |
Overrides
| Edit this page View SourceResolveIntegerValueAsync(string, int, EvaluationContext, CancellationToken)
Resolves a integer feature flag
Declaration
public override Task<ResolutionDetails<int>> ResolveIntegerValueAsync(string flagKey, int defaultValue, EvaluationContext context = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | flagKey | Feature flag key |
int | defaultValue | Default value |
EvaluationContext | context | OpenFeature.Model.EvaluationContext |
CancellationToken | cancellationToken | The CancellationToken. |
Returns
Type | Description |
---|---|
Task<ResolutionDetails<int>> | OpenFeature.Model.ResolutionDetails<T> |
Overrides
| Edit this page View SourceResolveStringValueAsync(string, string, EvaluationContext, CancellationToken)
Resolves a string feature flag
Declaration
public override Task<ResolutionDetails<string>> ResolveStringValueAsync(string flagKey, string defaultValue, EvaluationContext context = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | flagKey | Feature flag key |
string | defaultValue | Default value |
EvaluationContext | context | OpenFeature.Model.EvaluationContext |
CancellationToken | cancellationToken | The CancellationToken. |
Returns
Type | Description |
---|---|
Task<ResolutionDetails<string>> | OpenFeature.Model.ResolutionDetails<T> |
Overrides
| Edit this page View SourceResolveStructureValueAsync(string, Value, EvaluationContext, CancellationToken)
Resolves a structured feature flag
Declaration
public override Task<ResolutionDetails<Value>> ResolveStructureValueAsync(string flagKey, Value defaultValue, EvaluationContext context = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | flagKey | Feature flag key |
Value | defaultValue | Default value |
EvaluationContext | context | OpenFeature.Model.EvaluationContext |
CancellationToken | cancellationToken | The CancellationToken. |
Returns
Type | Description |
---|---|
Task<ResolutionDetails<Value>> | OpenFeature.Model.ResolutionDetails<T> |
Overrides
| Edit this page View SourceShutdownAsync(CancellationToken)
This method is called when a new provider is about to be used to evaluate flags, or the SDK is shut down. Providers can overwrite this method, if they have special shutdown actions needed.
Declaration
public override Task ShutdownAsync(CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | The CancellationToken to cancel any async side effects. |
Returns
Type | Description |
---|---|
Task | A task that completes when the shutdown process is complete. |