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

Commit

Permalink
prepare 1.0.0-beta21 release (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
eli-darkly authored Aug 8, 2019
1 parent f921dbf commit d4a90e6
Show file tree
Hide file tree
Showing 32 changed files with 289 additions and 279 deletions.
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,34 @@
All notable changes to the LaunchDarkly Client-side SDK for Xamarin will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org).

## [1.0.0-beta21] - 2019-08-06
### Added:
- `Configuration.Builder` provides a fluent builder pattern for constructing `Configuration` objects. This is now the only method for building a configuration if you want to set properties other than the SDK key.
- `ImmutableJsonValue.Null` (equivalent to `ImmutableJsonValue.Of(null)`).
- `LdClient.PlatformType`.
- Verbose debug logging for stream connections.

### Changed:
- `Configuration` objects are now immutable.
- In `Configuration`, `EventQueueCapacity` and `EventQueueFrency` have been renamed to `EventCapacity` and `EventFlushInterval`, for consistency with other LaunchDarkly SDKs.
- `ImmutableJsonValue.FromJToken()` was renamed to `ImmutableJsonValue.Of()`.
- In `FlagChangedEventArgs`, `NewValue` and `OldValue` now have the type `ImmutableJsonValue` instead of `JToken`.
- `ILdMobileClient` is now named `ILdClient`.

### Fixed:
- Fixed a bug where setting a user's custom attribute to a null value could cause an exception during JSON serialization of event data.

### Removed:
- `ConfigurationExtensions` (use `Configuration.Builder`).
- `Configuration.SamplingInterval`.
- `UserExtensions` (use `User.Builder`).
- `User` constructors (use `User.WithKey` or `User.Builder`).
- `User` property setters.
- `IBaseConfiguration` and `ICommonLdClient` interfaces.

## [1.0.0-beta20] - 2019-08-06
Incomplete release, replaced by beta21.

## [1.0.0-beta19] - 2019-07-31
### Added:
- `User.Builder` provides a fluent builder pattern for constructing `User` objects. This is now the only method for building a user if you want to set properties other than `Key`.
Expand Down
208 changes: 145 additions & 63 deletions src/LaunchDarkly.XamarinSdk/Configuration.cs

Large diffs are not rendered by default.

66 changes: 32 additions & 34 deletions src/LaunchDarkly.XamarinSdk/ConfigurationBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Net.Http;
using Common.Logging;
using LaunchDarkly.Client;
Expand Down Expand Up @@ -36,16 +35,21 @@ public interface IConfigurationBuilder
/// </summary>
/// <remarks>
/// If this is true, all of the user attributes will be private, not just the attributes specified with
/// <see cref="IUserBuilderCanMakeAttributePrivate.AsPrivateAttribute"/> on the <see cref="User"/> object.
/// <see cref="PrivateAttribute(string)"/> or with the <see cref="IUserBuilderCanMakeAttributePrivate.AsPrivateAttribute"/>
/// method with <see cref="UserBuilder"/>.
///
/// By default, this is false.
/// </remarks>
/// <param name="allAttributesPrivate">true if all attributes should be private</param>
/// <returns>the same builder</returns>
IConfigurationBuilder AllAttributesPrivate(bool allAttributesPrivate);

/// <summary>
/// Sets the interval for background polling.
/// </summary>
/// <summary>
/// Sets the interval between feature flag updates when the application is running in the background.
/// </summary>
/// <remarks>
/// This is only relevant on mobile platforms.
/// </remarks>
/// <param name="backgroundPollingInterval">the background polling interval</param>
/// <returns>the same builder</returns>
IConfigurationBuilder BackgroundPollingInterval(TimeSpan backgroundPollingInterval);
Expand All @@ -63,7 +67,7 @@ public interface IConfigurationBuilder
/// </summary>
/// <remarks>
/// The additional information will then be available through the client's "detail"
/// methods such as <see cref="ILdMobileClient.BoolVariationDetail(string, bool)"/>. Since this
/// methods such as <see cref="ILdClient.BoolVariationDetail(string, bool)"/>. Since this
/// increases the size of network requests, such information is not sent unless you set this option
/// to true.
/// </remarks>
Expand Down Expand Up @@ -94,18 +98,6 @@ public interface IConfigurationBuilder
/// <returns>the same builder</returns>
IConfigurationBuilder EventFlushInterval(TimeSpan eventflushInterval);

/// <summary>
/// Enables event sampling if non-zero.
/// </summary>
/// <remarks>
/// When set to the default of zero, all analytics events are sent back to LaunchDarkly. When greater
/// than zero, there is a 1 in <c>EventSamplingInterval</c> chance that events will be sent (example:
/// if the interval is 20, on average 5% of events will be sent).
/// </remarks>
/// <param name="eventSamplingInterval">the sampling interval</param>
/// <returns>the same builder</returns>
IConfigurationBuilder EventSamplingInterval(int eventSamplingInterval);

/// <summary>
/// Sets the base URL of the LaunchDarkly analytics event server.
/// </summary>
Expand Down Expand Up @@ -147,9 +139,13 @@ public interface IConfigurationBuilder
/// <param name="isStreamingEnabled">true if the streaming API should be used</param>
/// <returns>the same builder</returns>
IConfigurationBuilder IsStreamingEnabled(bool isStreamingEnabled);

/// <summary>
///
/// Sets the key for your LaunchDarkly environment.
/// </summary>
/// <remarks>
/// This should be the "mobile key" field for the environment on your LaunchDarkly dashboard.
/// </remarks>
/// <param name="mobileKey"></param>
/// <returns>the same builder</returns>
IConfigurationBuilder MobileKey(string mobileKey);
Expand All @@ -163,8 +159,11 @@ public interface IConfigurationBuilder

/// <summary>
/// Sets whether the SDK should save flag values for each user in persistent storage, so they will be
/// immediately available the next time the SDK is started for the same user. The default is <see langword="true"/>.
/// immediately available the next time the SDK is started for the same user.
/// </summary>
/// <remarks>
/// The default is <c>true</c>.
/// </remarks>
/// <param name="persistFlagValues">true to save flag values</param>
/// <returns>the same <c>Configuration</c> instance</returns>
/// <returns>the same builder</returns>
Expand All @@ -181,16 +180,18 @@ public interface IConfigurationBuilder
IConfigurationBuilder PollingInterval(TimeSpan pollingInterval);

/// <summary>
/// Marks an attribute name as private.
/// Marks an attribute name as private for all users.
/// </summary>
/// <remarks>
/// Any users sent to LaunchDarkly with this configuration active will have attributes with this name
/// removed, even if you did not use the <c>AndPrivate...</c> methods on the <see cref="User"/> object.
/// removed, even if you did not use the <see cref="IUserBuilderCanMakeAttributePrivate.AsPrivateAttribute"/>
/// method in <see cref="UserBuilder"/>.
///
/// You may call this method repeatedly to mark multiple attributes as private.
/// </remarks>
/// <param name="privateAtributeName">the attribute name</param>
/// <param name="privateAttributeName">the attribute name</param>
/// <returns>the same builder</returns>
IConfigurationBuilder PrivateAttribute(string privateAtributeName);
IConfigurationBuilder PrivateAttribute(string privateAttributeName);

/// <summary>
/// Sets the timeout when reading data from the streaming connection.
Expand Down Expand Up @@ -221,8 +222,13 @@ public interface IConfigurationBuilder
IConfigurationBuilder StreamUri(Uri streamUri);

/// <summary>
/// Determines whether to use the REPORT method for networking requests.
/// Sets whether to use the HTTP REPORT method for feature flag requests.
/// </summary>
/// <remarks>
/// By default, polling and streaming connections are made with the GET method, witht the user data
/// encoded into the request URI. Using REPORT allows the user data to be sent in the request body instead.
/// However, some network gateways do not support REPORT.
/// </remarks>
/// <param name="useReport">whether to use REPORT mode</param>
/// <returns>the same builder</returns>
IConfigurationBuilder UseReport(bool useReport);
Expand All @@ -249,7 +255,7 @@ public interface IConfigurationBuilder
IConfigurationBuilder UserKeysFlushInterval(TimeSpan userKeysFlushInterval);
}

internal class ConfigurationBuilder : IConfigurationBuilder
internal sealed class ConfigurationBuilder : IConfigurationBuilder
{
private static readonly ILog Log = LogManager.GetLogger(typeof(ConfigurationBuilder));

Expand All @@ -261,7 +267,6 @@ internal class ConfigurationBuilder : IConfigurationBuilder
internal bool _evaluationReasons = false;
internal int _eventCapacity = Configuration.DefaultEventCapacity;
internal TimeSpan _eventFlushInterval = Configuration.DefaultEventFlushInterval;
internal int _eventSamplingInterval = 0;
internal Uri _eventsUri = Configuration.DefaultEventsUri;
internal HttpClientHandler _httpClientHandler = new HttpClientHandler();
internal TimeSpan _httpClientTimeout = Configuration.DefaultHttpClientTimeout;
Expand Down Expand Up @@ -303,7 +308,6 @@ internal ConfigurationBuilder(Configuration copyFrom)
_evaluationReasons = copyFrom.EvaluationReasons;
_eventCapacity = copyFrom.EventCapacity;
_eventFlushInterval = copyFrom.EventFlushInterval;
_eventSamplingInterval = copyFrom.EventSamplingInterval;
_eventsUri = copyFrom.EventsUri;
_httpClientHandler = copyFrom.HttpClientHandler;
_httpClientTimeout = copyFrom.HttpClientTimeout;
Expand Down Expand Up @@ -384,12 +388,6 @@ public IConfigurationBuilder EventFlushInterval(TimeSpan eventflushInterval)
return this;
}

public IConfigurationBuilder EventSamplingInterval(int eventSamplingInterval)
{
_eventSamplingInterval = eventSamplingInterval;
return this;
}

public IConfigurationBuilder EventsUri(Uri eventsUri)
{
_eventsUri = eventsUri;
Expand Down
2 changes: 1 addition & 1 deletion src/LaunchDarkly.XamarinSdk/DefaultDeviceInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace LaunchDarkly.Xamarin
{
// This just delegates to the conditionally-compiled code in LaunchDarkly.Xamarin.PlatformSpecific.
// The only reason it is a pluggable component is for unit tests; we don't currently expose IDeviceInfo.
public class DefaultDeviceInfo : IDeviceInfo
internal sealed class DefaultDeviceInfo : IDeviceInfo
{
public string UniqueDeviceId()
{
Expand Down
2 changes: 1 addition & 1 deletion src/LaunchDarkly.XamarinSdk/DefaultPersistentStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace LaunchDarkly.Xamarin
{
internal class DefaultPersistentStorage : IPersistentStorage
internal sealed class DefaultPersistentStorage : IPersistentStorage
{
public void Save(string key, string value)
{
Expand Down
2 changes: 1 addition & 1 deletion src/LaunchDarkly.XamarinSdk/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace LaunchDarkly.Xamarin
{
public static class Extensions
internal static class Extensions
{
public static string Base64Encode(this string plainText)
{
Expand Down
4 changes: 2 additions & 2 deletions src/LaunchDarkly.XamarinSdk/Factory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ internal static IEventProcessor CreateEventProcessor(Configuration configuration
return new NullEventProcessor();
}

HttpClient httpClient = Util.MakeHttpClient(configuration, MobileClientEnvironment.Instance);
return new DefaultEventProcessor(configuration, null, httpClient, Constants.EVENTS_PATH);
HttpClient httpClient = Util.MakeHttpClient(configuration.HttpRequestConfiguration, MobileClientEnvironment.Instance);
return new DefaultEventProcessor(configuration.EventProcessorConfiguration, null, httpClient, Constants.EVENTS_PATH);
}

internal static IPersistentStorage CreatePersistentStorage(Configuration configuration)
Expand Down
2 changes: 1 addition & 1 deletion src/LaunchDarkly.XamarinSdk/FeatureFlag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace LaunchDarkly.Xamarin
{
public class FeatureFlag : IEquatable<FeatureFlag>
internal sealed class FeatureFlag : IEquatable<FeatureFlag>
{
public JToken value;
public int version;
Expand Down
23 changes: 10 additions & 13 deletions src/LaunchDarkly.XamarinSdk/FeatureFlagRequestor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@ internal interface IFeatureFlagRequestor : IDisposable
Task<WebResponse> FeatureFlagsAsync();
}

internal class FeatureFlagRequestor : IFeatureFlagRequestor
internal sealed class FeatureFlagRequestor : IFeatureFlagRequestor
{
private static readonly ILog Log = LogManager.GetLogger(typeof(FeatureFlagRequestor));
private static readonly HttpMethod ReportMethod = new HttpMethod("REPORT");

private readonly IMobileConfiguration _configuration;
private readonly Configuration _configuration;
private readonly User _currentUser;
private readonly HttpClient _httpClient;
private volatile EntityTagHeaderValue _etag;

internal FeatureFlagRequestor(IMobileConfiguration configuration, User user)
internal FeatureFlagRequestor(Configuration configuration, User user)
{
this._configuration = configuration;
this._httpClient = Util.MakeHttpClient(configuration, MobileClientEnvironment.Instance);
this._httpClient = Util.MakeHttpClient(configuration.HttpRequestConfiguration, MobileClientEnvironment.Instance);
this._currentUser = user;
}

Expand Down Expand Up @@ -121,19 +121,16 @@ private async Task<WebResponse> MakeRequest(HttpRequestMessage request)
}
}

protected virtual void Dispose(bool disposing)
// Sealed, non-derived class should implement Dispose() and finalize method, not Dispose(boolean)
public void Dispose()
{
if (disposing)
{
_httpClient.Dispose();
}
_httpClient.Dispose();
GC.SuppressFinalize(this);
}

// This code added to correctly implement the disposable pattern.
void IDisposable.Dispose()
~FeatureFlagRequestor()
{
Dispose(true);
GC.SuppressFinalize(this);
Dispose();
}
}
}
2 changes: 1 addition & 1 deletion src/LaunchDarkly.XamarinSdk/FlagCacheManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace LaunchDarkly.Xamarin
{
internal class FlagCacheManager : IFlagCacheManager
internal sealed class FlagCacheManager : IFlagCacheManager
{
private readonly IUserFlagCache inMemoryCache;
private readonly IUserFlagCache deviceCache;
Expand Down
Loading

0 comments on commit d4a90e6

Please sign in to comment.