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); }
/// <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); }