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="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, IEndPointDiscoverer endPointDiscoverer, string connectionName) { Ensure.NotNull(settings, "settings"); Ensure.NotNull(endPointDiscoverer, "endPointDiscoverer"); _connectionName = connectionName ?? string.Format("ES-{0}", Guid.NewGuid()); _settings = settings; _endPointDiscoverer = endPointDiscoverer; _handler = new EventStoreConnectionLogicHandler(this, settings); }
internal override Task<PersistentEventStoreSubscription> StartSubscription( string subscriptionId, string streamId, int bufferSize, UserCredentials userCredentials, Action<EventStoreSubscription, ResolvedEvent> onEventAppeared, Action<EventStoreSubscription, SubscriptionDropReason, Exception> onSubscriptionDropped, ConnectionSettings settings) { var source = new TaskCompletionSource<PersistentEventStoreSubscription>(); _handler.EnqueueMessage(new StartPersistentSubscriptionMessage(source, subscriptionId, streamId, bufferSize, userCredentials, onEventAppeared, onSubscriptionDropped, settings.MaxRetries, settings.OperationTimeout)); return source.Task; }
public EventStorePersistentSubscription( string subscriptionId, string streamId, Action<EventStorePersistentSubscriptionBase, ResolvedEvent> eventAppeared, Action<EventStorePersistentSubscriptionBase, SubscriptionDropReason, Exception> subscriptionDropped, UserCredentials userCredentials, ILogger log, bool verboseLogging, ConnectionSettings settings, EventStoreConnectionLogicHandler handler, int bufferSize = 10, bool autoAck = true) : base( subscriptionId, streamId, eventAppeared, subscriptionDropped, userCredentials, log, verboseLogging, settings, bufferSize, autoAck) { _handler = handler; }
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); }
public static EventFlowOptions UseEventStoreEventStore( this EventFlowOptions eventFlowOptions, IPEndPoint ipEndPoint, ConnectionSettings connectionSettings) { var eventStoreConnection = EventStoreConnection.Create(connectionSettings, ipEndPoint); using (var a = AsyncHelper.Wait) { a.Run(eventStoreConnection.ConnectAsync()); } return eventFlowOptions .RegisterServices(f => f.Register(r => eventStoreConnection, Lifetime.Singleton)) .UseEventStore<EventStoreEventStore>(); }
internal EventStorePersistentSubscriptionBase(string subscriptionId, string streamId, Action<EventStorePersistentSubscriptionBase, ResolvedEvent> eventAppeared, Action<EventStorePersistentSubscriptionBase, SubscriptionDropReason, Exception> subscriptionDropped, UserCredentials userCredentials, ILogger log, bool verboseLogging, ConnectionSettings settings, int bufferSize = 10, bool autoAck = true) { _subscriptionId = subscriptionId; _streamId = streamId; _eventAppeared = eventAppeared; _subscriptionDropped = subscriptionDropped; _userCredentials = userCredentials; _log = log; _verbose = verboseLogging; _settings = settings; _bufferSize = bufferSize; _autoAck = autoAck; }
/// <summary> /// Creates a new <see cref="IEventStoreConnection"/> to single node using specific <see cref="ConnectionSettings"/> /// </summary> /// <param name="settings">The <see cref="ConnectionSettings"/> to apply to the new connection</param> /// <param name="tcpEndPoint">The <see cref="IPEndPoint"/> to connect to.</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 settings, IPEndPoint tcpEndPoint, string connectionName = null) { Ensure.NotNull(settings, "settings"); Ensure.NotNull(tcpEndPoint, "tcpEndPoint"); return new EventStoreNodeConnection(settings, new StaticEndPointDiscoverer(tcpEndPoint, settings.UseSslConnection), 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); }
internal abstract Task<PersistentEventStoreSubscription> StartSubscription( string subscriptionId, string streamId, int bufferSize, UserCredentials userCredentials, Action<EventStoreSubscription, ResolvedEvent> onEventAppeared, Action<EventStoreSubscription, SubscriptionDropReason, Exception> onSubscriptionDropped, ConnectionSettings settings);
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)); }
public static IEventStoreConnection Create(ConnectionSettings settings, IPEndPoint tcpEndPoint, string connectionName = null) { return new EventStoreConnectionProfiler(EventStoreConnection.Create(settings, tcpEndPoint, connectionName)); }
/// <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> private EventStoreConnection(ConnectionSettings settings) { _settings = settings; LogManager.RegisterLogger(settings.Log); _log = LogManager.GetLogger(); _connector = new TcpConnector(); _subscriptionsChannel = new SubscriptionsChannel(_connector); }
/// <summary> /// Creates a new <see cref="EventStoreConnection"/> using specific <see cref="ConnectionSettings"/> /// </summary> /// <param name="settings">The <see cref="ConnectionSettings"/> to apply to the new connection</param> /// <returns>a new <see cref="EventStoreConnection"/></returns> public static EventStoreConnection Create(ConnectionSettings settings) { Ensure.NotNull(settings, "settings"); return new EventStoreConnection(settings); }
/// <summary> /// Creates a new <see cref="IEventStoreConnection"/> to single node using <see cref="ConnectionSettings"/> passed /// </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> /// <returns>a new <see cref="IEventStoreConnection"/></returns> public static IEventStoreConnection Create(ConnectionSettings connectionSettings, string connectionName = null) { return Create(connectionSettings, (Uri)null, connectionName); }