Skip to content

Commit

Permalink
obsolete GossipOverHttps
Browse files Browse the repository at this point in the history
  • Loading branch information
thefringeninja committed Jan 18, 2021
1 parent 5111ed0 commit 53cf860
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 22 deletions.
7 changes: 3 additions & 4 deletions src/EventStore.Client/ChannelFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,19 @@
namespace EventStore.Client {
internal static class ChannelFactory {
public static ChannelBase CreateChannel(EventStoreClientSettings settings, EndPoint endPoint) =>
CreateChannel(settings, endPoint.ToUri(settings.ConnectivitySettings.GossipOverHttps));
CreateChannel(settings, endPoint.ToUri(!settings.ConnectivitySettings.Insecure));

public static ChannelBase CreateChannel(EventStoreClientSettings settings, Uri? address) {
address ??= settings.ConnectivitySettings.Address;

#if !GRPC_CORE
if (address.Scheme == Uri.UriSchemeHttp ||!settings.ConnectivitySettings.GossipOverHttps) {
if (address.Scheme == Uri.UriSchemeHttp ||settings.ConnectivitySettings.Insecure) {
//this must be switched on before creation of the HttpMessageHandler
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
}

return GrpcChannel.ForAddress(address, new GrpcChannelOptions {
HttpClient = new HttpClient(CreateHandler(),
true) {
HttpClient = new HttpClient(CreateHandler(), true) {
Timeout = Timeout.InfiniteTimeSpan,
DefaultRequestVersion = new Version(2, 0),
},
Expand Down
10 changes: 9 additions & 1 deletion src/EventStore.Client/EventStoreClientConnectivitySettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,14 @@ public class EventStoreClientConnectivitySettings {
/// </summary>
public TimeSpan GossipTimeout { get; set; }

#if !NETFRAMEWORK

/// <summary>
/// Whether or not to use HTTPS when communicating via gossip.
/// </summary>
[Obsolete]
public bool GossipOverHttps { get; set; } = true;
#endif

/// <summary>
/// The polling interval used to discover the <see cref="EndPoint"/>.
Expand All @@ -70,13 +74,17 @@ public class EventStoreClientConnectivitySettings {
/// </summary>
public bool IsSingleNode => GossipSeeds.Length == 0;

/// <summary>
/// True if communicating over a secure channel; otherwise false.
/// </summary>
public bool Insecure { get; set; }

/// <summary>
/// The default <see cref="EventStoreClientConnectivitySettings"/>.
/// </summary>
public static EventStoreClientConnectivitySettings Default => new EventStoreClientConnectivitySettings {
MaxDiscoverAttempts = 10,
GossipTimeout = TimeSpan.FromSeconds(5),
GossipOverHttps = true,
DiscoveryInterval = TimeSpan.FromMilliseconds(100),
NodePreference = NodePreference.Leader
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ private static EventStoreClientSettings CreateSettings(string scheme, (string us
settings.ConnectivitySettings.KeepAlive = TimeSpan.FromMilliseconds((int)keepAliveMs);
}

connSettings.Insecure = !useTls;

if (hosts.Length == 1 && scheme != UriSchemeDiscover) {
connSettings.Address = hosts[0].ToUri(useTls);
} else {
Expand All @@ -178,8 +180,6 @@ private static EventStoreClientSettings CreateSettings(string scheme, (string us
Array.ConvertAll(hosts, x => new DnsEndPoint(x.GetHost(), x.GetPort()));
else
connSettings.IpGossipSeeds = Array.ConvertAll(hosts, x => x as IPEndPoint);

connSettings.GossipOverHttps = useTls;
}

#if !GRPC_CORE
Expand Down
18 changes: 9 additions & 9 deletions test/EventStore.Client.Tests/ConnectionStringTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public void with_valid_single_node_connection_string() {
Assert.Empty(settings.ConnectivitySettings.GossipSeeds);
Assert.Null(settings.ConnectivitySettings.IpGossipSeeds);
Assert.Null(settings.ConnectivitySettings.DnsGossipSeeds);
Assert.True(settings.ConnectivitySettings.GossipOverHttps);
Assert.False(settings.ConnectivitySettings.Insecure);
Assert.Equal(13, settings.ConnectivitySettings.MaxDiscoverAttempts);
Assert.Equal(37, settings.ConnectivitySettings.DiscoveryInterval.TotalMilliseconds);
Assert.Equal(NodePreference.Follower, settings.ConnectivitySettings.NodePreference);
Expand All @@ -153,7 +153,7 @@ public void with_valid_single_node_connection_string() {
Assert.Empty(settings.ConnectivitySettings.GossipSeeds);
Assert.Null(settings.ConnectivitySettings.IpGossipSeeds);
Assert.Null(settings.ConnectivitySettings.DnsGossipSeeds);
Assert.True(settings.ConnectivitySettings.GossipOverHttps);
Assert.True(settings.ConnectivitySettings.Insecure);
Assert.Null(settings.ConnectivitySettings.KeepAlive);
#if !GRPC_CORE
Assert.NotNull(settings.CreateHttpMessageHandler);
Expand All @@ -178,8 +178,8 @@ public void with_default_settings() {
settings.ConnectivitySettings.MaxDiscoverAttempts);
Assert.Equal(EventStoreClientConnectivitySettings.Default.NodePreference,
settings.ConnectivitySettings.NodePreference);
Assert.Equal(EventStoreClientConnectivitySettings.Default.GossipOverHttps,
settings.ConnectivitySettings.GossipOverHttps);
Assert.Equal(EventStoreClientConnectivitySettings.Default.Insecure,
settings.ConnectivitySettings.Insecure);
Assert.Equal(EventStoreClientOperationOptions.Default.TimeoutAfter!.Value.TotalMilliseconds,
settings.OperationOptions.TimeoutAfter!.Value.TotalMilliseconds);
Assert.Equal(EventStoreClientOperationOptions.Default.ThrowOnAppendFailure,
Expand All @@ -197,7 +197,7 @@ public void with_valid_cluster_connection_string() {
Assert.NotEmpty(settings.ConnectivitySettings.GossipSeeds);
Assert.NotNull(settings.ConnectivitySettings.IpGossipSeeds);
Assert.Null(settings.ConnectivitySettings.DnsGossipSeeds);
Assert.True(settings.ConnectivitySettings.GossipOverHttps);
Assert.False(settings.ConnectivitySettings.Insecure);
Assert.True(settings.ConnectivitySettings.IpGossipSeeds.Length == 3 &&
Equals(settings.ConnectivitySettings.IpGossipSeeds[0].Address, IPAddress.Parse("127.0.0.1")) &&
Equals(settings.ConnectivitySettings.IpGossipSeeds[0].Port, 2113) &&
Expand All @@ -221,7 +221,7 @@ public void with_valid_cluster_connection_string() {
Assert.NotEmpty(settings.ConnectivitySettings.GossipSeeds);
Assert.Null(settings.ConnectivitySettings.IpGossipSeeds);
Assert.NotNull(settings.ConnectivitySettings.DnsGossipSeeds);
Assert.False(settings.ConnectivitySettings.GossipOverHttps);
Assert.True(settings.ConnectivitySettings.Insecure);
Assert.True(settings.ConnectivitySettings.DnsGossipSeeds.Length == 3 &&
Equals(settings.ConnectivitySettings.DnsGossipSeeds[0].Host, "host1") &&
Equals(settings.ConnectivitySettings.DnsGossipSeeds[0].Port, 2113) &&
Expand Down Expand Up @@ -252,13 +252,13 @@ public void with_different_tls_settings() {
Assert.Equal(Uri.UriSchemeHttp, settings.ConnectivitySettings.Address.Scheme);

settings = EventStoreClientSettings.Create("esdb://127.0.0.1,127.0.0.2:3321,127.0.0.3/");
Assert.True(settings.ConnectivitySettings.GossipOverHttps);
Assert.False(settings.ConnectivitySettings.Insecure);

settings = EventStoreClientSettings.Create("esdb://127.0.0.1,127.0.0.2:3321,127.0.0.3?tls=true");
Assert.True(settings.ConnectivitySettings.GossipOverHttps);
Assert.False(settings.ConnectivitySettings.Insecure);

settings = EventStoreClientSettings.Create("esdb://127.0.0.1,127.0.0.2:3321,127.0.0.3/?tls=fAlSe");
Assert.False(settings.ConnectivitySettings.GossipOverHttps);
Assert.True(settings.ConnectivitySettings.Insecure);
}

#if !GRPC_CORE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public async Task should_issue_gossip_to_gossip_seed(bool useHttps) {
new EventStoreClientConnectivitySettings {
MaxDiscoverAttempts = 1,
GossipTimeout = Timeout.InfiniteTimeSpan,
GossipOverHttps = useHttps,
Insecure = !useHttps,
DiscoveryInterval = TimeSpan.Zero,
NodePreference = NodePreference.Leader,
DnsGossipSeeds = new[] {_gossipSeed}
Expand Down Expand Up @@ -78,7 +78,7 @@ public async Task should_be_able_to_discover_twice(bool useHttps) {
new EventStoreClientConnectivitySettings {
MaxDiscoverAttempts = 5,
GossipTimeout = Timeout.InfiniteTimeSpan,
GossipOverHttps = useHttps,
Insecure = !useHttps,
DiscoveryInterval = TimeSpan.Zero,
NodePreference = NodePreference.Leader,
DnsGossipSeeds = new[] {_gossipSeed}
Expand Down Expand Up @@ -107,7 +107,7 @@ public async Task should_not_exceed_max_discovery_attempts(bool useHttps) {
new EventStoreClientConnectivitySettings {
MaxDiscoverAttempts = 5,
GossipTimeout = Timeout.InfiniteTimeSpan,
GossipOverHttps = useHttps,
Insecure = !useHttps,
DiscoveryInterval = TimeSpan.Zero,
NodePreference = NodePreference.Leader,
DnsGossipSeeds = new[] {_gossipSeed}
Expand Down Expand Up @@ -156,7 +156,7 @@ internal async Task should_not_be_able_to_pick_invalid_node(bool useHttps,
new EventStoreClientConnectivitySettings {
MaxDiscoverAttempts = 1,
GossipTimeout = Timeout.InfiniteTimeSpan,
GossipOverHttps = useHttps,
Insecure = !useHttps,
DiscoveryInterval = TimeSpan.Zero,
NodePreference = NodePreference.Leader,
DnsGossipSeeds = new[] {_gossipSeed}
Expand Down Expand Up @@ -209,7 +209,7 @@ internal async Task should_pick_node_based_on_preference(bool useHttps, NodePref
new EventStoreClientConnectivitySettings {
MaxDiscoverAttempts = 1,
GossipTimeout = Timeout.InfiniteTimeSpan,
GossipOverHttps = useHttps,
Insecure = !useHttps,
DiscoveryInterval = TimeSpan.Zero,
NodePreference = preference,
DnsGossipSeeds = new[] {_gossipSeed}
Expand Down Expand Up @@ -243,7 +243,7 @@ public async Task falls_back_to_first_alive_node_if_a_preferred_node_is_not_foun
new EventStoreClientConnectivitySettings {
MaxDiscoverAttempts = 1,
GossipTimeout = Timeout.InfiniteTimeSpan,
GossipOverHttps = useHttps,
Insecure = !useHttps,
DiscoveryInterval = TimeSpan.Zero,
NodePreference = NodePreference.Leader,
DnsGossipSeeds = new[] {_gossipSeed}
Expand Down

0 comments on commit 53cf860

Please sign in to comment.