示例#1
0
        public SocketClient(Uri uri, SocketSettings socketSettings, BufferSettings bufferSettings,
                            IConnectionListener connMetricsListener = null, ILogger logger = null, ITcpSocketClient socketClient = null)
        {
            _uri             = uri;
            _logger          = logger;
            _bufferSettings  = bufferSettings;
            _tcpSocketClient = socketClient ?? new TcpSocketClient(socketSettings, _logger);

            _connMetricsListener = connMetricsListener;
            if (_connMetricsListener != null)
            {
                _connEvent = new SimpleTimerEvent();
            }
        }
        public PooledConnection(IConnection conn, IConnectionReleaseManager releaseManager = null,
                                IConnectionListener connMetricsListener = null)
            : base(conn)
        {
            _releaseManager = releaseManager;
            // IdleTimer starts to count when the connection is put back to the pool.
            IdleTimer = new StopwatchBasedTimer();
            // LifetimeTimer starts to count once the connection is created.
            LifetimeTimer = new StopwatchBasedTimer();
            LifetimeTimer.Start();

            _connMetricsListener = connMetricsListener;
            if (_connMetricsListener != null)
            {
                _connEvent = new SimpleTimerEvent();
            }
        }
 public void PoolAcquiring(IListenerEvent listenerEvent)
 {
     Interlocked.Increment(ref _acquiring);
     listenerEvent.Start();
 }
 public void PoolAcquired(IListenerEvent listenerEvent)
 {
     Interlocked.Decrement(ref _acquiring);
     Interlocked.Increment(ref _acquired);
     _histogram.RecordValue(listenerEvent.GetElapsed());
 }
示例#5
0
 public void ConnectionReleased(IListenerEvent connEvent)
 {
     _inUseTimeHistogram.RecordValue(connEvent.GetElapsed());
 }
示例#6
0
 public void ConnectionAcquired(IListenerEvent connEvent)
 {
     connEvent.Start();
 }
示例#7
0
 public void ConnectionConnected(IListenerEvent connEvent)
 {
     _connectionTimeHistogram.RecordValue(connEvent.GetElapsed());
 }
示例#8
0
 public void ConnectionConnecting(IListenerEvent connEvent)
 {
     connEvent.Start();
 }