Ejemplo n.º 1
0
        private IConnection BorrowLeastBusyConnection(IConnection[] connections)
        {
            var c = HostConnectionPool.MinInFlight(connections, ref _connectionIndex, _maxRequestsPerConnection, out var inFlight);

            if (inFlight >= _maxRequestsPerConnection)
            {
                throw new BusyPoolException(_host.Address, _maxRequestsPerConnection, connections.Length);
            }

            ConsiderResizingPool(inFlight);
            return(c);
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public async Task <IConnection> BorrowConnection()
        {
            var connections = await EnsureCreate().ConfigureAwait(false);

            if (connections.Length == 0)
            {
                throw new DriverInternalError("No connection could be borrowed");
            }

            var c = HostConnectionPool.MinInFlight(connections, ref _connectionIndex, _maxRequestsPerConnection, out var inFlight);

            if (inFlight >= _maxRequestsPerConnection)
            {
                throw new BusyPoolException(c.Address, _maxRequestsPerConnection, connections.Length);
            }

            ConsiderResizingPool(inFlight);
            return(c);
        }