private void StartConnection(TaskCompletionSource<object> task, IEndPointDiscoverer endPointDiscoverer)
        {
            Ensure.NotNull(task, "task");
            Ensure.NotNull(endPointDiscoverer, "endPointDiscoverer");

            LogDebug("StartConnection");

            switch (_state)
            {
                case ConnectionState.Init:
                {
                    _endPointDiscoverer = endPointDiscoverer;
                    _state = ConnectionState.Connecting;
                    _connectingPhase = ConnectingPhase.Reconnecting;
                    DiscoverEndPoint(task);
                    break;
                }
                case ConnectionState.Connecting:
                case ConnectionState.Connected:
                {
                    task.SetException(new InvalidOperationException(
                        string.Format("EventStoreConnection '{0}' is already active.", _esConnection.ConnectionName)));
                    break;
                }
                case ConnectionState.Closed:
                    task.SetException(new ObjectDisposedException(_esConnection.ConnectionName));
                    break;
                default: throw new Exception(string.Format("Unknown state: {0}", _state));
            }
        }
Example #2
0
        private void StartConnection(TaskCompletionSource <object> task, IEndPointDiscoverer endPointDiscoverer)
        {
            Ensure.NotNull(task, "task");
            Ensure.NotNull(endPointDiscoverer, "endPointDiscoverer");

            LogDebug("StartConnection");

            switch (_state)
            {
            case ConnectionState.Init:
            {
                _endPointDiscoverer = endPointDiscoverer;
                _state           = ConnectionState.Connecting;
                _connectingPhase = ConnectingPhase.Reconnecting;
                DiscoverEndPoint(task);
                break;
            }

            case ConnectionState.Connecting:
            case ConnectionState.Connected:
            {
                task.SetException(new InvalidOperationException(
                                      string.Format("EventStoreConnection '{0}' is already active.", _esConnection.ConnectionName)));
                break;
            }

            case ConnectionState.Closed:
                task.SetException(new ObjectDisposedException(_esConnection.ConnectionName));
                break;

            default: throw new Exception(string.Format("Unknown state: {0}", _state));
            }
        }
Example #3
0
 /// <summary>
 /// Creates a new <see cref="IEventStoreConnection"/> using specific <see cref="ConnectionSettings"/> and a custom-defined <see cref="IEndPointDiscoverer"/>
 /// </summary>
 /// <param name="connectionSettings">The <see cref="ConnectionSettings"/> to apply to the new connection</param>
 /// <param name="endPointDiscoverer">The custom-defined <see cref="IEndPointDiscoverer"/> to use for node discovery</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,
                                            IEndPointDiscoverer endPointDiscoverer, string connectionName = null)
 {
     Ensure.NotNull(connectionSettings, "settings");
     Ensure.NotNull(endPointDiscoverer, "endPointDiscoverer");
     return(new EventStoreNodeConnection(connectionSettings, null, endPointDiscoverer, connectionName));
 }
Example #4
0
        public StartConnectionMessage(TaskCompletionSource <object> task, IEndPointDiscoverer endPointDiscoverer)
        {
            Ensure.NotNull(task, "task");
            Ensure.NotNull(endPointDiscoverer, "endendPointDiscoverer");

            Task = task;
            EndPointDiscoverer = endPointDiscoverer;
        }
Example #5
0
 public StartConnectionMessage(TaskCompletionSource<object> task, IEndPointDiscoverer endPointDiscoverer)
 {
     Ensure.NotNull(task, "task");
     Ensure.NotNull(endPointDiscoverer, "endendPointDiscoverer");
     
     Task = task;
     EndPointDiscoverer = endPointDiscoverer;
 }
        /// <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);
        }
        /// <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);
        }
        /// <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">The <see cref="ClusterSettings" /> 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, ClusterSettings clusterSettings,
                                          IEndPointDiscoverer endPointDiscoverer, string connectionName)
        {
            Ensure.NotNull(settings, "settings");
            Ensure.NotNull(endPointDiscoverer, "endPointDiscoverer");

            ConnectionName      = connectionName ?? $"ES-{Guid.NewGuid()}";
            Settings            = settings;
            ClusterSettings     = clusterSettings;
            _endPointDiscoverer = endPointDiscoverer;
            _handler            = new EventStoreConnectionLogicHandler(this, settings);
        }