public EventStoreConnection(IPEndPoint tcpEndPoint,
                                    int maxConcurrentRequests   = 50,
                                    int maxAttemptsForOperation = 10,
                                    int maxReconnections        = 10,
                                    ILogger logger = null)
        {
            Ensure.NotNull(tcpEndPoint, "tcpEndPoint");
            Ensure.Positive(maxConcurrentRequests, "maxConcurrentRequests");
            Ensure.Nonnegative(maxAttemptsForOperation, "maxAttemptsForOperation");
            Ensure.Nonnegative(maxReconnections, "maxReconnections");

            _tcpEndPoint        = tcpEndPoint;
            _maxConcurrentItems = maxConcurrentRequests;
            _maxAttempts        = maxAttemptsForOperation;
            _maxReconnections   = maxReconnections;

            LogManager.RegisterLogger(logger);
            _log = LogManager.GetLogger();

            _connector            = new TcpConnector(_tcpEndPoint);
            _subscriptionsChannel = new SubscriptionsChannel(_connector);
            //TODO TD: WAT?
            _projectionsManager = new ProjectionsManager(new IPEndPoint(_tcpEndPoint.Address, _tcpEndPoint.Port + 1000));

            _lastReconnectionTimestamp = DateTime.UtcNow;
            _connection = _connector.CreateTcpConnection(OnPackageReceived, OnConnectionEstablished, OnConnectionClosed);
            _timeoutCheckStopwatch.Start();

            _worker = new Thread(MainLoop)
            {
                IsBackground = true,
                Name         = "Worker thread"
            };
            _worker.Start();
        }
        private EventStoreConnection(bool allowForwarding,
                                     int maxConcurrentRequests,
                                     int maxAttemptsForOperation,
                                     int maxReconnections,
                                     ILogger logger)
        {
            _allowForwarding    = allowForwarding;
            _maxConcurrentItems = maxConcurrentRequests;
            _maxAttempts        = maxAttemptsForOperation;
            _maxReconnections   = maxReconnections;

            LogManager.RegisterLogger(logger);
            _log = LogManager.GetLogger();

            _connector            = new TcpConnector();
            _subscriptionsChannel = new SubscriptionsChannel(_connector);
            _projectionsManager   = new ProjectionsManager();
        }
Exemple #3
0
        public EventStoreConnection(IPEndPoint tcpEndPoint)
        {
            Ensure.NotNull(tcpEndPoint, "tcpEndPoint");

            _tcpEndPoint           = tcpEndPoint;
            _connector             = new TcpConnector(_tcpEndPoint);
            _outstandingOperations = new ConcurrentDictionary <Guid, ITaskCompletionWrapper>();

            _lastReconnectionTimestamp = DateTime.UtcNow;
            _connection = _connector.CreateTcpConnection(OnPackageReceived, ConnectionEstablished, ConnectionClosed);
            _timeoutCheckStopwatch.Start();

            _monitoringThread = new Thread(MonitoringLoop)
            {
                IsBackground = true,
                Name         = string.Format("Monitoring thread")
            };
            _monitoringThread.Start();
        }
        public EventStoreConnection(IPEndPoint tcpEndPoint)
        {
            Ensure.NotNull(tcpEndPoint, "tcpEndPoint");

            _tcpEndPoint = tcpEndPoint;
            _connector = new TcpConnector(_tcpEndPoint);
            _outstandingOperations = new ConcurrentDictionary<Guid, ITaskCompletionWrapper>();

            _lastReconnectionTimestamp = DateTime.UtcNow;
            _connection = _connector.CreateTcpConnection(OnPackageReceived, ConnectionEstablished, ConnectionClosed);
            _timeoutCheckStopwatch.Start();

            _monitoringThread = new Thread(MonitoringLoop)
            {
                IsBackground = true,
                Name = string.Format("Monitoring thread")
            };
            _monitoringThread.Start();
        }