Skip to content

Commit

Permalink
remove/obsolete createHttpMessageHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
thefringeninja committed Jan 6, 2021
1 parent 0e10327 commit fe48b73
Show file tree
Hide file tree
Showing 7 changed files with 182 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@ namespace Microsoft.Extensions.DependencyInjection {
/// A set of extension methods for <see cref="IServiceCollection"/> which provide support for an <see cref="EventStoreOperationsClient"/>.
/// </summary>
public static class EventStoreOperationsClientServiceCollectionExtensions {
#if GRPC_CORE
/// <summary>
/// Adds an <see cref="EventStoreOperationsClient"/> to the <see cref="IServiceCollection"/>.
/// </summary>
/// <param name="services"></param>
/// <param name="address"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public static IServiceCollection AddEventStoreOperationsClient(this IServiceCollection services, Uri address)
=> services.AddEventStoreOperationsClient(options => {
options.ConnectivitySettings.Address = address;
});
#else
/// <summary>
/// Adds an <see cref="EventStoreOperationsClient"/> to the <see cref="IServiceCollection"/>.
/// </summary>
Expand All @@ -29,7 +42,24 @@ public static IServiceCollection AddEventStoreOperationsClient(this IServiceColl
options.ConnectivitySettings.Address = address;
options.CreateHttpMessageHandler = createHttpMessageHandler;
});
#endif

#if NETCOREAPP3_1
/// <summary>
/// Adds an <see cref="EventStoreOperationsClient"/> to the <see cref="IServiceCollection"/>.
/// </summary>
/// <param name="services"></param>
/// <param name="address"></param>
/// <param name="createHttpMessageHandler"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public static IServiceCollection AddEventStoreOperationsClient(this IServiceCollection services, Uri address,
// ReSharper disable once MethodOverloadWithOptionalParameter
Func<HttpMessageHandler>? createHttpMessageHandler = null)
=> services.AddEventStoreOperationsClient(options => {
options.ConnectivitySettings.Address = address;
});
#endif
/// <summary>
/// Adds an <see cref="EventStoreOperationsClient"/> to the <see cref="IServiceCollection"/>.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ namespace Microsoft.Extensions.DependencyInjection {
/// A set of extension methods for <see cref="IServiceCollection"/> which provide support for an <see cref="EventStorePersistentSubscriptionsClient"/>.
/// </summary>
public static class EventStorePersistentSubscriptionsClientCollectionExtensions {
#if GRPC_CORE
/// <summary>
/// Adds an <see cref="EventStorePersistentSubscriptionsClient"/> to the <see cref="IServiceCollection"/>.
/// </summary>
/// <param name="services"></param>
/// <param name="address"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public static IServiceCollection AddEventStorePersistentSubscriptionsClient(this IServiceCollection services,
Uri address)
=> services.AddEventStorePersistentSubscriptionsClient(options => {
options.ConnectivitySettings.Address = address;
});
#else
/// <summary>
/// Adds an <see cref="EventStorePersistentSubscriptionsClient"/> to the <see cref="IServiceCollection"/>.
/// </summary>
Expand All @@ -22,12 +36,31 @@ public static class EventStorePersistentSubscriptionsClientCollectionExtensions
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public static IServiceCollection AddEventStorePersistentSubscriptionsClient(this IServiceCollection services,
Uri address,
Func<HttpMessageHandler>? createHttpMessageHandler = null)
Uri address, Func<HttpMessageHandler>? createHttpMessageHandler = null)
=> services.AddEventStorePersistentSubscriptionsClient(options => {
options.ConnectivitySettings.Address = address;
options.CreateHttpMessageHandler = createHttpMessageHandler;
});
#endif

#if NETCOREAPP3_1
/// <summary>
/// Adds an <see cref="EventStorePersistentSubscriptionsClient"/> to the <see cref="IServiceCollection"/>.
/// </summary>
/// <param name="services"></param>
/// <param name="address"></param>
/// <param name="createHttpMessageHandler"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
[Obsolete]
public static IServiceCollection AddEventStorePersistentSubscriptionsClient(this IServiceCollection services,
// ReSharper disable once MethodOverloadWithOptionalParameter
Uri address, Func<HttpMessageHandler>? createHttpMessageHandler = null)
=> services.AddEventStorePersistentSubscriptionsClient(options => {
options.ConnectivitySettings.Address = address;
options.CreateHttpMessageHandler = createHttpMessageHandler;
});
#endif

/// <summary>
/// Adds an <see cref="EventStorePersistentSubscriptionsClient"/> to the <see cref="IServiceCollection"/>.
Expand Down Expand Up @@ -61,14 +94,12 @@ private static IServiceCollection AddEventStorePersistentSubscriptionsClient(thi
}

configureSettings?.Invoke(settings);

services.TryAddSingleton(provider => {
settings.LoggerFactory ??= provider.GetService<ILoggerFactory>();
settings.Interceptors ??= provider.GetServices<Interceptor>();

return new EventStorePersistentSubscriptionsClient(settings);
});

return services;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ namespace Microsoft.Extensions.DependencyInjection {
/// A set of extension methods for <see cref="IServiceCollection"/> which provide support for an <see cref="EventStoreProjectionManagementClient"/>.
/// </summary>
public static class EventStoreProjectionManagementClientCollectionExtensions {
#if GRPC_CORE
/// <summary>
/// Adds an <see cref="EventStoreProjectionManagementClient"/> to the <see cref="IServiceCollection"/>.
/// </summary>
/// <param name="services"></param>
/// <param name="address"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public static IServiceCollection AddEventStoreProjectionManagementClient(this IServiceCollection services,
Uri address)
=> services.AddEventStoreProjectionManagementClient(options => {
options.ConnectivitySettings.Address = address;
});
#else
/// <summary>
/// Adds an <see cref="EventStoreProjectionManagementClient"/> to the <see cref="IServiceCollection"/>.
/// </summary>
Expand All @@ -28,7 +42,26 @@ public static IServiceCollection AddEventStoreProjectionManagementClient(this IS
options.ConnectivitySettings.Address = address;
options.CreateHttpMessageHandler = createHttpMessageHandler;
});
#endif

#if NETCOREAPP3_1
/// <summary>
/// Adds an <see cref="EventStoreProjectionManagementClient"/> to the <see cref="IServiceCollection"/>.
/// </summary>
/// <param name="services"></param>
/// <param name="address"></param>
/// <param name="createHttpMessageHandler"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
[Obsolete]
public static IServiceCollection AddEventStoreProjectionManagementClient(this IServiceCollection services,
// ReSharper disable once MethodOverloadWithOptionalParameter
Uri address, Func<HttpMessageHandler>? createHttpMessageHandler = null)
=> services.AddEventStoreProjectionManagementClient(options => {
options.ConnectivitySettings.Address = address;
options.CreateHttpMessageHandler = createHttpMessageHandler;
});
#endif
/// <summary>
/// Adds an <see cref="EventStoreProjectionManagementClient"/> to the <see cref="IServiceCollection"/>.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ namespace Microsoft.Extensions.DependencyInjection {
/// A set of extension methods for <see cref="IServiceCollection"/> which provide support for an <see cref="EventStoreClient"/>.
/// </summary>
public static class EventStoreClientServiceCollectionExtensions {
#if GRPC_CORE
/// <summary>
/// Adds an <see cref="EventStoreClient"/> to the <see cref="IServiceCollection"/>.
/// </summary>
/// <param name="services"></param>
/// <param name="address"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public static IServiceCollection AddEventStoreClient(this IServiceCollection services, Uri address)
=> services.AddEventStoreClient(options => {
options.ConnectivitySettings.Address = address;
});
#else
/// <summary>
/// Adds an <see cref="EventStoreClient"/> to the <see cref="IServiceCollection"/>.
/// </summary>
Expand All @@ -27,8 +40,24 @@ public static IServiceCollection AddEventStoreClient(this IServiceCollection ser
options.ConnectivitySettings.Address = address;
options.CreateHttpMessageHandler = createHttpMessageHandler;
});
#endif


#if NETCOREAPP3_1
/// <summary>
/// Adds an <see cref="EventStoreClient"/> to the <see cref="IServiceCollection"/>.
/// </summary>
/// <param name="services"></param>
/// <param name="address"></param>
/// <param name="createHttpMessageHandler"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public static IServiceCollection AddEventStoreClient(this IServiceCollection services, Uri address,
// ReSharper disable once MethodOverloadWithOptionalParameter
Func<HttpMessageHandler>? createHttpMessageHandler = null)
=> services.AddEventStoreClient(options => {
options.ConnectivitySettings.Address = address;
});
#endif
/// <summary>
/// Adds an <see cref="EventStoreClient"/> to the <see cref="IServiceCollection"/>.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ namespace Microsoft.Extensions.DependencyInjection {
/// A set of extension methods for <see cref="IServiceCollection"/> which provide support for an <see cref="EventStoreUserManagementClient"/>.
/// </summary>
public static class EventStoreUserManagementClientCollectionExtensions {
#if GRPC_CORE
/// <summary>
/// Adds an <see cref="EventStoreUserManagementClient"/> to the <see cref="IServiceCollection"/>.
/// </summary>
/// <param name="services"></param>
/// <param name="address"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public static IServiceCollection AddEventStoreUserManagementClient(this IServiceCollection services,
Uri address)
=> services.AddEventStoreUserManagementClient(options => {
options.ConnectivitySettings.Address = address;
});
#else
/// <summary>
/// Adds an <see cref="EventStoreUserManagementClient"/> to the <see cref="IServiceCollection"/>.
/// </summary>
Expand All @@ -27,6 +41,26 @@ public static IServiceCollection AddEventStoreUserManagementClient(this IService
options.ConnectivitySettings.Address = address;
options.CreateHttpMessageHandler = createHttpMessageHandler;
});
#endif

#if NETCOREAPP3_1
/// <summary>
/// Adds an <see cref="EventStoreUserManagementClient"/> to the <see cref="IServiceCollection"/>.
/// </summary>
/// <param name="services"></param>
/// <param name="address"></param>
/// <param name="createHttpMessageHandler"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
[Obsolete]
public static IServiceCollection AddEventStoreUserManagementClient(this IServiceCollection services,
// ReSharper disable once MethodOverloadWithOptionalParameter
Uri address, Func<HttpMessageHandler>? createHttpMessageHandler = null)
=> services.AddEventStoreUserManagementClient(options => {
options.ConnectivitySettings.Address = address;
});

#endif

/// <summary>
/// Adds an <see cref="EventStoreUserManagementClient"/> to the <see cref="IServiceCollection"/>.
Expand Down
5 changes: 5 additions & 0 deletions src/EventStore.Client/EventStoreClientSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,16 @@ public partial class EventStoreClientSettings {
/// </summary>
public string? ConnectionName { get; set; }

#if !NETFRAMEWORK
/// <summary>
/// An optional <see cref="HttpMessageHandler"/> factory.
/// </summary>
#if NETCOREAPP3_1
[Obsolete]
#endif
public Func<HttpMessageHandler>? CreateHttpMessageHandler { get; set; }

#endif
/// <summary>
/// An optional <see cref="ILoggerFactory"/> to use.
/// </summary>
Expand Down
15 changes: 15 additions & 0 deletions test/EventStore.Client.Tests/ConnectionStringTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,12 @@ public void with_valid_single_node_connection_string() {
Assert.Equal(37, settings.ConnectivitySettings.DiscoveryInterval.TotalMilliseconds);
Assert.Equal(33, settings.ConnectivitySettings.GossipTimeout.TotalMilliseconds);
Assert.Equal(NodePreference.Follower, settings.ConnectivitySettings.NodePreference);
#if !GRPC_CORE
#if !GRPC_CORE
Assert.NotNull(settings.CreateHttpMessageHandler);
#endif

#endif
settings = EventStoreClientSettings.Create(
"esdb://127.0.0.1?connectionName=test&maxDiscoverAttempts=13&DiscoveryInterval=37&nOdEPrEfErence=FoLLoWer&tls=true&tlsVerifyCert=true&operationTimeout=330&throwOnAppendFailure=faLse");
Assert.Null(settings.DefaultCredentials);
Expand All @@ -135,7 +139,10 @@ public void with_valid_single_node_connection_string() {
Assert.Equal(13, settings.ConnectivitySettings.MaxDiscoverAttempts);
Assert.Equal(37, settings.ConnectivitySettings.DiscoveryInterval.TotalMilliseconds);
Assert.Equal(NodePreference.Follower, settings.ConnectivitySettings.NodePreference);
#if !GRPC_CORE
Assert.Null(settings.CreateHttpMessageHandler);
#endif

Assert.Equal(330, settings.OperationOptions.TimeoutAfter.Value.TotalMilliseconds);
Assert.False(settings.OperationOptions.ThrowOnAppendFailure);

Expand All @@ -146,7 +153,9 @@ public void with_valid_single_node_connection_string() {
Assert.Null(settings.ConnectivitySettings.IpGossipSeeds);
Assert.Null(settings.ConnectivitySettings.DnsGossipSeeds);
Assert.True(settings.ConnectivitySettings.GossipOverHttps);
#if !GRPC_CORE
Assert.Null(settings.CreateHttpMessageHandler);
#endif
}

[Fact]
Expand Down Expand Up @@ -198,7 +207,9 @@ public void with_valid_cluster_connection_string() {
Assert.Equal(13, settings.ConnectivitySettings.MaxDiscoverAttempts);
Assert.Equal(37, settings.ConnectivitySettings.DiscoveryInterval.TotalMilliseconds);
Assert.Equal(NodePreference.Follower, settings.ConnectivitySettings.NodePreference);
#if !GRPC_CORE
Assert.NotNull(settings.CreateHttpMessageHandler);
#endif


settings = EventStoreClientSettings.Create(
Expand All @@ -219,7 +230,9 @@ public void with_valid_cluster_connection_string() {
Assert.Equal(13, settings.ConnectivitySettings.MaxDiscoverAttempts);
Assert.Equal(37, settings.ConnectivitySettings.DiscoveryInterval.TotalMilliseconds);
Assert.Equal(NodePreference.Follower, settings.ConnectivitySettings.NodePreference);
#if !GRPC_CORE
Assert.NotNull(settings.CreateHttpMessageHandler);
#endif
}

[Fact]
Expand All @@ -245,6 +258,7 @@ public void with_different_tls_settings() {
Assert.False(settings.ConnectivitySettings.GossipOverHttps);
}

#if !GRPC_CORE
[Fact]
public void with_different_tls_verify_cert_settings() {
EventStoreClientSettings settings;
Expand All @@ -268,6 +282,7 @@ public void with_different_tls_verify_cert_settings() {
"esdb://127.0.0.1,127.0.0.2:3321,127.0.0.3/?tlsVerifyCert=false");
Assert.NotNull(settings.CreateHttpMessageHandler);
}
#endif

public static IEnumerable<object[]> DiscoverSchemeCases() {
yield return new object[] {
Expand Down

0 comments on commit fe48b73

Please sign in to comment.