public ConnectionConfiguration( ConnectionSettings connectionSettings, ClusterSettings clusterSettings, IPEndPoint singleNodeAddress, IPEndPoint httpEndpoint, string name) { if (connectionSettings == null) { throw new ArgumentNullException("connectionSettings"); } if (httpEndpoint == null) { throw new ArgumentNullException("httpEndpoint"); } if (clusterSettings == null && singleNodeAddress == null) { throw new ArgumentException("Either clusterSettings or singleNodeAddress must be specified."); } if (clusterSettings != null && singleNodeAddress != null) { throw new ArgumentException("Either clusterSettings or singleNodeAddress must be specified but not both."); } this.connectionSettings = connectionSettings; this.clusterSettings = clusterSettings; this.singleNodeAddress = singleNodeAddress; this.httpEndpoint = httpEndpoint; this.name = name; }
/// <summary> /// Creates a new <see cref="IEventStoreConnection"/> to single node using default <see cref="ConnectionSettings"/> /// </summary> /// <param name="connectionName">Optional name of connection (will be generated automatically, if not provided)</param> /// <param name="connectionSettings">The <see cref="ConnectionSettings"/> to apply to the new connection</param> /// <param name="uri">The Uri to connect to. It can be tcp:// to point to a single node or discover:// to discover nodes via dns</param> /// <returns>a new <see cref="IEventStoreConnection"/></returns> public static IEventStoreConnection Create(ConnectionSettings connectionSettings, Uri uri, string connectionName = null) { var scheme = uri == null ? "" : uri.Scheme.ToLower(); connectionSettings = connectionSettings ?? ConnectionSettings.Default; var credential = GetCredentialFromUri(uri); if (credential != null) { connectionSettings = new ConnectionSettings(connectionSettings.Log, connectionSettings.VerboseLogging, connectionSettings.MaxQueueSize, connectionSettings.MaxConcurrentItems, connectionSettings.MaxRetries, connectionSettings.MaxReconnections, connectionSettings.RequireMaster, connectionSettings.ReconnectionDelay, connectionSettings.OperationTimeout, connectionSettings.OperationTimeoutCheckPeriod, credential, connectionSettings.UseSslConnection, connectionSettings.TargetHost, connectionSettings.ValidateServer, connectionSettings.FailOnNoServerResponse, connectionSettings.HeartbeatInterval, connectionSettings.HeartbeatTimeout, connectionSettings.ClientConnectionTimeout, connectionSettings.ClusterDns, connectionSettings.GossipSeeds, connectionSettings.MaxDiscoverAttempts, connectionSettings.ExternalGossipPort, connectionSettings.GossipTimeout); } if (scheme == "discover") { var clusterSettings = new ClusterSettings(uri.Host, connectionSettings.MaxDiscoverAttempts, uri.Port, connectionSettings.GossipTimeout); Ensure.NotNull(connectionSettings, "connectionSettings"); Ensure.NotNull(clusterSettings, "clusterSettings"); var endPointDiscoverer = new ClusterDnsEndPointDiscoverer(connectionSettings.Log, clusterSettings.ClusterDns, clusterSettings.MaxDiscoverAttempts, clusterSettings.ExternalGossipPort, clusterSettings.GossipSeeds, clusterSettings.GossipTimeout); return new EventStoreNodeConnection(connectionSettings, clusterSettings, endPointDiscoverer, connectionName); } if (scheme == "tcp") { var tcpEndPoint = GetSingleNodeIPEndPointFrom(uri); return new EventStoreNodeConnection(connectionSettings, null, new StaticEndPointDiscoverer(tcpEndPoint, connectionSettings.UseSslConnection), connectionName); } if (connectionSettings.GossipSeeds != null && connectionSettings.GossipSeeds.Length > 0) { var clusterSettings = new ClusterSettings(connectionSettings.GossipSeeds, connectionSettings.MaxDiscoverAttempts, connectionSettings.GossipTimeout); Ensure.NotNull(connectionSettings, "connectionSettings"); Ensure.NotNull(clusterSettings, "clusterSettings"); var endPointDiscoverer = new ClusterDnsEndPointDiscoverer(connectionSettings.Log, clusterSettings.ClusterDns, clusterSettings.MaxDiscoverAttempts, clusterSettings.ExternalGossipPort, clusterSettings.GossipSeeds, clusterSettings.GossipTimeout); return new EventStoreNodeConnection(connectionSettings, clusterSettings, endPointDiscoverer, connectionName); } throw new Exception(string.Format("Unknown scheme for connection '{0}'", scheme)); }
/// <summary> /// Constructs a new instance of a <see cref="EventStoreConnection"/> /// </summary> /// <param name="settings">The <see cref="ConnectionSettings"/> containing the settings for this connection.</param> /// <param name="clusterSettings"></param> /// <param name="endPointDiscoverer">Discoverer of destination node end point.</param> /// <param name="connectionName">Optional name of connection (will be generated automatically, if not provided)</param> internal EventStoreNodeConnection(ConnectionSettings settings, ClusterSettings clusterSettings, IEndPointDiscoverer endPointDiscoverer, string connectionName) { Ensure.NotNull(settings, "settings"); Ensure.NotNull(endPointDiscoverer, "endPointDiscoverer"); _connectionName = connectionName ?? string.Format("ES-{0}", Guid.NewGuid()); _settings = settings; _clusterSettings = clusterSettings; _endPointDiscoverer = endPointDiscoverer; _handler = new EventStoreConnectionLogicHandler(this, settings); }
internal EventStoreClusterConnection(ConnectionSettings connectionSettings, ClusterSettings clusterSettings, string connectionName) { var endPointDiscoverer = new ClusterDnsEndPointDiscoverer(connectionSettings.Log, clusterSettings.ClusterDns, clusterSettings.MaxDiscoverAttempts, clusterSettings.ManagerExternalHttpPort, clusterSettings.FakeDnsEntries, clusterSettings.GossipTimeout); _conn = new EventStoreNodeConnection(connectionSettings, 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.ExternalGossipPort, clusterSettings.GossipSeeds, clusterSettings.GossipTimeout); return new EventStoreNodeConnection(connectionSettings, 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 handler = connectionSettings.CustomHttpMessageHandler; if (handler is null) { if (!connectionSettings.ValidateServer) { #if NET452 connectionSettings.Log.Info( "Setting the Http Message Handler via connection settings is not supported in .NET 4.5.2"); #else handler = new HttpClientHandler { ServerCertificateCustomValidationCallback = delegate { return(true); } }; #endif } } 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.ExternalGossipPort, clusterSettings.GossipSeeds, clusterSettings.GossipTimeout); return(new EventStoreNodeConnection(connectionSettings, clusterSettings, endPointDiscoverer, connectionName)); }
/// <summary> /// Creates a new <see cref="IEventStoreConnection"/> /// </summary> /// <param name="connectionName">Optional name of connection (will be generated automatically, if not provided)</param> /// <param name="connectionSettings">The <see cref="ConnectionSettings"/> to apply to the new connection. If null the default settings will be used and the <paramref name="uri"/> must not be null</param> /// <param name="uri">The Uri to connect to. It can be tcp:// to point to a single node or discover:// to discover nodes via dns or null to connect using the gossip seeds from the <paramref name="connectionSettings"/></param> /// <returns>a new <see cref="IEventStoreConnection"/></returns> /// <remarks>You must pass a uri or set gossip seeds in the connection settings.</remarks> public static IEventStoreConnection Create(ConnectionSettings connectionSettings, Uri uri, string connectionName = null) { connectionSettings = connectionSettings ?? ConnectionSettings.Default; if (uri != null) { var scheme = uri.Scheme.ToLower(); var credential = GetCredentialFromUri(uri); if (credential != null) { connectionSettings = new ConnectionSettings(connectionSettings.Log, connectionSettings.VerboseLogging, connectionSettings.MaxQueueSize, connectionSettings.MaxConcurrentItems, connectionSettings.MaxRetries, connectionSettings.MaxReconnections, connectionSettings.RequireMaster, connectionSettings.ReconnectionDelay, connectionSettings.OperationTimeout, connectionSettings.OperationTimeoutCheckPeriod, credential, connectionSettings.UseSslConnection, connectionSettings.TargetHost, connectionSettings.ValidateServer, connectionSettings.FailOnNoServerResponse, connectionSettings.HeartbeatInterval, connectionSettings.HeartbeatTimeout, connectionSettings.ClientConnectionTimeout, connectionSettings.ClusterDns, connectionSettings.GossipSeeds, connectionSettings.MaxDiscoverAttempts, connectionSettings.ExternalGossipPort, connectionSettings.GossipTimeout, connectionSettings.PreferRandomNode, connectionSettings.CustomHttpClientHandler); } if (scheme == "discover") { var clusterSettings = new ClusterSettings(uri.Host, connectionSettings.MaxDiscoverAttempts, uri.Port, connectionSettings.GossipTimeout, connectionSettings.PreferRandomNode); Ensure.NotNull(connectionSettings, "connectionSettings"); Ensure.NotNull(clusterSettings, "clusterSettings"); var endPointDiscoverer = new ClusterDnsEndPointDiscoverer(connectionSettings.Log, clusterSettings.ClusterDns, clusterSettings.MaxDiscoverAttempts, clusterSettings.ExternalGossipPort, clusterSettings.GossipSeeds, clusterSettings.GossipTimeout, clusterSettings.PreferRandomNode, connectionSettings.CustomHttpClientHandler); return(new EventStoreNodeConnection(connectionSettings, clusterSettings, endPointDiscoverer, connectionName)); } if (scheme == "tcp") { return(new EventStoreNodeConnection(connectionSettings, null, new SingleEndpointDiscoverer(uri, connectionSettings.UseSslConnection), connectionName)); } throw new Exception(string.Format("Unknown scheme for connection '{0}'", scheme)); } if (connectionSettings.GossipSeeds != null && connectionSettings.GossipSeeds.Length > 0) { var clusterSettings = new ClusterSettings(connectionSettings.GossipSeeds, connectionSettings.MaxDiscoverAttempts, connectionSettings.GossipTimeout, connectionSettings.PreferRandomNode); Ensure.NotNull(connectionSettings, "connectionSettings"); Ensure.NotNull(clusterSettings, "clusterSettings"); var endPointDiscoverer = new ClusterDnsEndPointDiscoverer(connectionSettings.Log, clusterSettings.ClusterDns, clusterSettings.MaxDiscoverAttempts, clusterSettings.ExternalGossipPort, clusterSettings.GossipSeeds, clusterSettings.GossipTimeout, clusterSettings.PreferRandomNode, connectionSettings.CustomHttpClientHandler); return(new EventStoreNodeConnection(connectionSettings, clusterSettings, endPointDiscoverer, connectionName)); } throw new Exception($"Must specify uri or gossip seeds"); }
/// <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"); return new EventStoreClusterConnection(connectionSettings, clusterSettings, connectionName); }
public static void UseEventStore(this ProjectionGatewayConfiguration projectionGatewayConfiguration, ConnectionSettings connection, ClusterSettings clusterSettings, IPEndPoint tcpEndpoint) { var eventStoreConnection = EventStoreConnection.Create(connection, clusterSettings); ProjectionManager.Configure(projectionGatewayConfiguration, tcpEndpoint, connection.DefaultUserCredentials); Start(projectionGatewayConfiguration, eventStoreConnection); }
public static IEventStoreConnection Create(ConnectionSettings connectionSettings, ClusterSettings clusterSettings, string connectionName = null) { return new EventStoreConnectionProfiler(EventStoreConnection.Create(connectionSettings, clusterSettings, 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"); return(new EventStoreClusterConnection(connectionSettings, clusterSettings, connectionName)); }