Skip to content
This repository has been archived by the owner on Oct 30, 2024. It is now read-only.

Commit

Permalink
prepare 8.1.0 release (#186)
Browse files Browse the repository at this point in the history
## [8.1.0] - 2024-03-06
### Added:
- Added the ability to set wrapper information independent of HTTP
configuration. This change is intended primarily for use by LaunchDarkly
in the development of wrapper SDKs.

---------

Co-authored-by: Eli Bishop <[email protected]>
Co-authored-by: Ben Woskow <[email protected]>
Co-authored-by: LaunchDarklyCI <[email protected]>
Co-authored-by: LaunchDarklyCI <[email protected]>
Co-authored-by: Ember Stevens <[email protected]>
Co-authored-by: ember-stevens <[email protected]>
Co-authored-by: LaunchDarklyReleaseBot <[email protected]>
Co-authored-by: Ryan Lamb <[email protected]>
Co-authored-by: Louis Chan <[email protected]>
Co-authored-by: ld-repository-standards[bot] <113625520+ld-repository-standards[bot]@users.noreply.github.com>
Co-authored-by: Kane Parkinson <[email protected]>
  • Loading branch information
12 people authored Mar 6, 2024
1 parent 9cf1678 commit ed9c699
Show file tree
Hide file tree
Showing 14 changed files with 253 additions and 31 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ local.properties
# PDT-specific
.buildpath

global.json


#################
## Visual Studio
Expand Down
10 changes: 10 additions & 0 deletions src/LaunchDarkly.ServerSdk/Components.cs
Original file line number Diff line number Diff line change
Expand Up @@ -413,5 +413,15 @@ public static StreamingDataSourceBuilder StreamingDataSource() =>
/// </example>
/// <returns>a configuration builder</returns>
public static ApplicationInfoBuilder ApplicationInfo() => new ApplicationInfoBuilder();

/// <summary>
/// Returns a configuration builder for setting wrapper information. Applications do not need to call this
/// method.
/// </summary>
/// <remarks>
/// This is intended for use by LaunchDarkly in the development of wrapper SDKs.
/// </remarks>
/// <returns>a configuration builder</returns>
public static WrapperInfoBuilder WrapperInfo() => new WrapperInfoBuilder();
}
}
8 changes: 8 additions & 0 deletions src/LaunchDarkly.ServerSdk/Configuration.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using LaunchDarkly.Sdk.Server.Integrations;
using LaunchDarkly.Sdk.Server.Interfaces;
using LaunchDarkly.Sdk.Server.Subsystems;

Expand Down Expand Up @@ -99,6 +100,12 @@ public class Configuration
/// </summary>
public ApplicationInfoBuilder ApplicationInfo { get; }

/// <summary>
/// WrapperInfo configuration which contains wrapper configuration. This is primarily intended for use by
/// LaunchDarkly when developing wrapper SDKs.
/// </summary>
public WrapperInfoBuilder WrapperInfo { get; }

#endregion

#region Public methods
Expand Down Expand Up @@ -174,6 +181,7 @@ internal Configuration(ConfigurationBuilder builder)
ServiceEndpoints = (builder._serviceEndpointsBuilder ?? Components.ServiceEndpoints()).Build();
StartWaitTime = builder._startWaitTime;
ApplicationInfo = builder._applicationInfo;
WrapperInfo = builder._wrapperInfo;
}

#endregion
Expand Down
16 changes: 16 additions & 0 deletions src/LaunchDarkly.ServerSdk/ConfigurationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public sealed class ConfigurationBuilder
internal ServiceEndpointsBuilder _serviceEndpointsBuilder = null;
internal TimeSpan _startWaitTime = DefaultStartWaitTime;
internal ApplicationInfoBuilder _applicationInfo;
internal WrapperInfoBuilder _wrapperInfo;

#endregion

Expand Down Expand Up @@ -343,6 +344,21 @@ public ConfigurationBuilder ApplicationInfo(ApplicationInfoBuilder applicationIn
return this;
}

/// <summary>
/// Set the wrapper information.
/// </summary>
/// <remarks>
/// This is intended for use with wrapper SDKs from LaunchDarkly. Additionally, any wrapper SDK may overwrite
/// any application developer provided wrapper information.
/// </remarks>
/// <param name="wrapperInfo">the wrapper builder</param>
/// <returns>the same builder</returns>
public ConfigurationBuilder WrapperInfo(WrapperInfoBuilder wrapperInfo)
{
_wrapperInfo = wrapperInfo;
return this;
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,18 @@ public HttpConfiguration Build(LdClientContext context)

private HttpProperties MakeHttpProperties(LdClientContext context)
{
string wrapperName;
string wrapperVersion;
if (context.WrapperInfo != null)
{
wrapperName = context.WrapperInfo.Name;
wrapperVersion = context.WrapperInfo.Version;
}
else
{
wrapperName = _wrapperName;
wrapperVersion = _wrapperVersion;
}
var httpProperties = HttpProperties.Default
.WithAuthorizationKey(context.SdkKey)
.WithConnectTimeout(_connectTimeout)
Expand All @@ -244,7 +256,7 @@ private HttpProperties MakeHttpProperties(LdClientContext context)
.WithReadTimeout(_readTimeout)
.WithUserAgent("DotNetClient/" + AssemblyVersions.GetAssemblyVersionStringForType(typeof(LdClient)))
.WithApplicationTags(context.ApplicationInfo)
.WithWrapper(_wrapperName, _wrapperVersion);
.WithWrapper(wrapperName, wrapperVersion);

return _customHeaders.Aggregate(httpProperties, (current, kv)
=> current.WithHeader(kv.Key, kv.Value));
Expand Down
54 changes: 54 additions & 0 deletions src/LaunchDarkly.ServerSdk/Integrations/WrapperInfoBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using LaunchDarkly.Sdk.Server.Interfaces;

namespace LaunchDarkly.Sdk.Server.Integrations
{
/// <summary>
/// Contains methods for configuring wrapper information.
/// <para>
/// If the WrapperBuilder is used, then it will replace the wrapper information from the HttpConfigurationBuilder.
/// </para>
/// <para>
/// Additionally, any wrapper SDK may overwrite any application developer provided wrapper information.
/// </para>
/// </summary>
/// <remarks>
/// This builder is primarily intended for use by LaunchDarkly in developing wrapper SDKs.
/// </remarks>
public sealed class WrapperInfoBuilder
{
private string _name;
private string _version;

/// <summary>
/// Set the name of the wrapper.
/// </summary>
/// <param name="value">the name of the wrapper</param>
/// <returns>the builder</returns>
public WrapperInfoBuilder Name(string value)
{
_name = value;
return this;
}

/// <summary>
/// Set the version of the wrapper.
/// </summary>
/// <param name="value">the version of the wrapper</param>
/// <returns>the builder</returns>
public WrapperInfoBuilder Version(string value)
{
_version = value;
return this;
}

/// <summary>
/// Called internally by the SDK to create a configuration instance. Applications do not need
/// to call this method.
/// </summary>
/// <returns>the wrapper information</returns>
public WrapperInfo Build()
{
return new WrapperInfo(_name, _version);
}
}
}
24 changes: 24 additions & 0 deletions src/LaunchDarkly.ServerSdk/Interfaces/WrapperInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace LaunchDarkly.Sdk.Server.Interfaces
{
/// <summary>
/// Contains wrapper SDK information.
/// </summary>
/// <remarks>
/// This class's properties are not public, since they are only read by the SDK.
/// </remarks>
/// <seealso cref="LaunchDarkly.Sdk.Server.Integrations.WrapperInfoBuilder"/>
public sealed class WrapperInfo
{
internal string Name { get; }
internal string Version { get; }

internal WrapperInfo(
string name,
string version
)
{
Name = name;
Version = version;
}
}
}
14 changes: 7 additions & 7 deletions src/LaunchDarkly.ServerSdk/LdClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public sealed class LdClient : IDisposable, ILdClient
/// var client = new LDClient(config);
/// </code>
/// </example>
/// <seealso cref="LdClient.LdClient(string)"/>
/// <seealso cref="LdClient(string)"/>
public LdClient(Configuration config)
{
_configuration = config;
Expand All @@ -140,19 +140,19 @@ public LdClient(Configuration config)
config.ServiceEndpoints,
null,
taskExecutor,
config.ApplicationInfo?.Build() ?? new ApplicationInfo()
config.ApplicationInfo?.Build() ?? new ApplicationInfo(),
config.WrapperInfo?.Build()
);

var httpConfig = (config.Http ?? Components.HttpConfiguration()).Build(clientContext);
clientContext = clientContext.WithHttp(httpConfig);

ServerDiagnosticStore diagnosticStore = _configuration.DiagnosticOptOut ? null :
var diagnosticStore = _configuration.DiagnosticOptOut ? null :
new ServerDiagnosticStore(config, clientContext);
clientContext = clientContext.WithDiagnosticStore(diagnosticStore);

var dataStoreUpdates = new DataStoreUpdatesImpl(taskExecutor, _log.SubLogger(LogNames.DataStoreSubLog));

var contextForDataStore = clientContext.WithDataStoreUpdates(dataStoreUpdates);
_dataStore = (_configuration.DataStore ?? Components.InMemoryDataStore)
.Build(clientContext.WithDataStoreUpdates(dataStoreUpdates));
_dataStoreStatusProvider = new DataStoreStatusProviderImpl(_dataStore, dataStoreUpdates);
Expand Down Expand Up @@ -219,7 +219,7 @@ public LdClient(Configuration config)
/// </summary>
/// <remarks>
/// <para>
/// If you need to specify any custom SDK options, use <see cref="LdClient.LdClient(Configuration)"/>
/// If you need to specify any custom SDK options, use <see cref="LdClient(Configuration)"/>
/// instead.
/// </para>
/// <para>
Expand All @@ -231,11 +231,11 @@ public LdClient(Configuration config)
/// <para>
/// The constructor will never throw an exception, even if initialization fails. For more details
/// about initialization behavior and how to detect error conditions, see
/// <see cref="LdClient.LdClient(Configuration)"/>.
/// <see cref="LdClient(Configuration)"/>.
/// </para>
/// </remarks>
/// <param name="sdkKey">the SDK key for your LaunchDarkly environment</param>
/// <seealso cref="LdClient.LdClient(Configuration)"/>
/// <seealso cref="LdClient(Configuration)"/>
public LdClient(string sdkKey) : this(Configuration.Default(sdkKey))
{
}
Expand Down
Loading

0 comments on commit ed9c699

Please sign in to comment.