/// <summary> /// Creates a new <see cref="IEventStoreConnection"/> to EventStore cluster /// using specific <see cref="ConnectionSettings"/> and <see cref="ClusterSettings"/> /// </summary> /// <param name="connectionSettings">The <see cref="ConnectionSettings"/> to apply to the new connection</param> /// <param name="clusterSettings">The <see cref="ClusterSettings"/> that determine cluster behavior.</param> /// <param name="connectionName">Optional name of connection (will be generated automatically, if not provided)</param> /// <returns>a new <see cref="IEventStoreConnection"/></returns> public static IEventStoreConnection Create(ConnectionSettings connectionSettings, ClusterSettings clusterSettings, string connectionName = null) { Ensure.NotNull(connectionSettings, "connectionSettings"); Ensure.NotNull(clusterSettings, "clusterSettings"); var handler = connectionSettings.CustomHttpMessageHandler; if (handler is null && !connectionSettings.ValidateServer) { handler = new HttpClientHandler { ServerCertificateCustomValidationCallback = delegate { return(true); } }; } var discoverClient = new HttpAsyncClient(connectionSettings.GossipTimeout, handler); var endPointDiscoverer = new ClusterDnsEndPointDiscoverer(connectionSettings.Log, clusterSettings.ClusterDns, clusterSettings.MaxDiscoverAttempts, clusterSettings.HttpPort, clusterSettings.GossipSeeds, clusterSettings.GossipTimeout, clusterSettings.NodePreference, CompatibilityMode.Create(connectionSettings.CompatibilityMode), discoverClient); return(new EventStoreNodeConnection(connectionSettings, clusterSettings, endPointDiscoverer, connectionName)); }
/// <summary> /// Creates a new <see cref="IEventStoreConnection"/> to EventStore cluster /// using specific <see cref="ConnectionSettings"/> and <see cref="ClusterSettings"/> /// </summary> /// <param name="connectionSettings">The <see cref="ConnectionSettings"/> to apply to the new connection</param> /// <param name="clusterSettings">The <see cref="ClusterSettings"/> that determine cluster behavior.</param> /// <param name="connectionName">Optional name of connection (will be generated automatically, if not provided)</param> /// <returns>a new <see cref="IEventStoreConnection"/></returns> public static IEventStoreConnection Create(ConnectionSettings connectionSettings, ClusterSettings clusterSettings, string connectionName = null) { Ensure.NotNull(connectionSettings, "connectionSettings"); Ensure.NotNull(clusterSettings, "clusterSettings"); var endPointDiscoverer = new ClusterDnsEndPointDiscoverer(connectionSettings.Log, clusterSettings.ClusterDns, clusterSettings.MaxDiscoverAttempts, clusterSettings.HttpPort, clusterSettings.GossipSeeds, clusterSettings.GossipTimeout, clusterSettings.NodePreference, CompatibilityMode.Create(connectionSettings.CompatibilityMode), connectionSettings.CustomHttpMessageHandler); return(new EventStoreNodeConnection(connectionSettings, clusterSettings, endPointDiscoverer, connectionName)); }