Skip to content

Commit

Permalink
feat: Update to SDK 8.1.0. Support wrapper headers. (#29)
Browse files Browse the repository at this point in the history
This updates to the 8.1.0 SDK and adds configuration for setting the
wrapper name and version.
  • Loading branch information
kinyoklion committed Apr 8, 2024
1 parent 3f48713 commit 08c1fa5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="LaunchDarkly.ServerSdk" Version="[8.0,9.0)" />
<PackageReference Include="LaunchDarkly.ServerSdk" Version="[8.1.0,9.0)" />
<PackageReference Include="OpenFeature" Version="[1.4.0, 2.0.0)" />
</ItemGroup>

Expand Down
16 changes: 12 additions & 4 deletions src/LaunchDarkly.OpenFeature.ServerProvider/Provider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ internal Provider(ILdClient client)
/// Construct a new instance of the provider with the given configuration.
/// </summary>
/// <param name="config">A client configuration object</param>
public Provider(Configuration config) : this(new LdClient(config))
public Provider(Configuration config) : this(new LdClient(WrapConfig(config)))
{
}

/// <summary>
/// Construct a new instance of the provider with the given SDK key.
/// </summary>
/// <param name="sdkKey">The SDK key</param>
public Provider(string sdkKey) : this(new LdClient(sdkKey))
public Provider(string sdkKey) : this(new LdClient(WrapConfig(Configuration.Builder(sdkKey).Build())))
{
}

Expand All @@ -83,6 +83,14 @@ public ILdClient GetClient()
return _client;
}

private static Configuration WrapConfig(Configuration config)
{
return Configuration.Builder(config)
.WrapperInfo(Components.WrapperInfo().Name("open-feature-dotnet-server")
.Version(typeof(Provider).Assembly.GetName().Version.ToString()))
.Build();
}

#region FeatureProvider Implementation

/// <inheritdoc />
Expand Down Expand Up @@ -180,10 +188,10 @@ await EventChannel.Writer.WriteAsync(new ProviderEventPayload
{
ProviderName = _metadata.Name,
Type = ProviderEventTypes.ProviderConfigurationChanged,
FlagsChanged = new List<string>{changeEvent.Key},
FlagsChanged = new List<string> {changeEvent.Key},
}).ConfigureAwait(false);
}
catch(Exception e)
catch (Exception e)
{
_logger.Warn($"Encountered an error sending configuration changed events: {e.Message}");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="LaunchDarkly.ServerSdk" Version="8.0.0" />
<PackageReference Include="LaunchDarkly.ServerSdk" Version="8.1.0" />
<PackageReference Include="LaunchDarkly.TestHelpers" Version="2.0.0" />
<PackageReference Include="Moq" Version="4.8.1" />
<PackageReference Include="OpenFeature" Version="1.*" />
Expand Down

0 comments on commit 08c1fa5

Please sign in to comment.