Skip to content

Commit 08c1fa5

Browse files
authored
feat: Update to SDK 8.1.0. Support wrapper headers. (#29)
This updates to the 8.1.0 SDK and adds configuration for setting the wrapper name and version.
1 parent 3f48713 commit 08c1fa5

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

src/LaunchDarkly.OpenFeature.ServerProvider/LaunchDarkly.OpenFeature.ServerProvider.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
</ItemGroup>
4141

4242
<ItemGroup>
43-
<PackageReference Include="LaunchDarkly.ServerSdk" Version="[8.0,9.0)" />
43+
<PackageReference Include="LaunchDarkly.ServerSdk" Version="[8.1.0,9.0)" />
4444
<PackageReference Include="OpenFeature" Version="[1.4.0, 2.0.0)" />
4545
</ItemGroup>
4646

src/LaunchDarkly.OpenFeature.ServerProvider/Provider.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ internal Provider(ILdClient client)
5252
/// Construct a new instance of the provider with the given configuration.
5353
/// </summary>
5454
/// <param name="config">A client configuration object</param>
55-
public Provider(Configuration config) : this(new LdClient(config))
55+
public Provider(Configuration config) : this(new LdClient(WrapConfig(config)))
5656
{
5757
}
5858

5959
/// <summary>
6060
/// Construct a new instance of the provider with the given SDK key.
6161
/// </summary>
6262
/// <param name="sdkKey">The SDK key</param>
63-
public Provider(string sdkKey) : this(new LdClient(sdkKey))
63+
public Provider(string sdkKey) : this(new LdClient(WrapConfig(Configuration.Builder(sdkKey).Build())))
6464
{
6565
}
6666

@@ -83,6 +83,14 @@ public ILdClient GetClient()
8383
return _client;
8484
}
8585

86+
private static Configuration WrapConfig(Configuration config)
87+
{
88+
return Configuration.Builder(config)
89+
.WrapperInfo(Components.WrapperInfo().Name("open-feature-dotnet-server")
90+
.Version(typeof(Provider).Assembly.GetName().Version.ToString()))
91+
.Build();
92+
}
93+
8694
#region FeatureProvider Implementation
8795

8896
/// <inheritdoc />
@@ -180,10 +188,10 @@ await EventChannel.Writer.WriteAsync(new ProviderEventPayload
180188
{
181189
ProviderName = _metadata.Name,
182190
Type = ProviderEventTypes.ProviderConfigurationChanged,
183-
FlagsChanged = new List<string>{changeEvent.Key},
191+
FlagsChanged = new List<string> {changeEvent.Key},
184192
}).ConfigureAwait(false);
185193
}
186-
catch(Exception e)
194+
catch (Exception e)
187195
{
188196
_logger.Warn($"Encountered an error sending configuration changed events: {e.Message}");
189197
}

test/LaunchDarkly.OpenFeature.ServerProvider.Tests/LaunchDarkly.OpenFeature.ServerProvider.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3030
<PrivateAssets>all</PrivateAssets>
3131
</PackageReference>
32-
<PackageReference Include="LaunchDarkly.ServerSdk" Version="8.0.0" />
32+
<PackageReference Include="LaunchDarkly.ServerSdk" Version="8.1.0" />
3333
<PackageReference Include="LaunchDarkly.TestHelpers" Version="2.0.0" />
3434
<PackageReference Include="Moq" Version="4.8.1" />
3535
<PackageReference Include="OpenFeature" Version="1.*" />

0 commit comments

Comments
 (0)