Method: Mongo::Server::ConnectionPool#populate

Defined in:
lib/mongo/server/connection_pool.rb

#populatetrue | false

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method does three things:

  1. Creates and adds a connection to the pool, if the pool’s size is below min_size. Retries once if a socket-related error is encountered during this process and raises if a second error or a non socket-related error occurs.

  2. Removes stale connections from the connection pool.

  3. Interrupts connections marked for interruption.

Used by the pool populator background thread.

occured, or the non socket-related error

Returns:

  • (true | false)

    Whether this method should be called again to create more connections.

Raises:

Since:

  • 2.0.0, largely rewritten in 2.9.0



793
794
795
796
797
798
799
800
801
802
803
804
805
# File 'lib/mongo/server/connection_pool.rb', line 793

def populate
  return false if closed?

  begin
    return create_and_add_connection
  rescue Error::SocketError, Error::SocketTimeoutError => e
    # an error was encountered while connecting the connection,
    # ignore this first error and try again.
    log_warn("Populator failed to connect a connection for #{address}: #{e.class}: #{e}. It will retry.")
  end

  return create_and_add_connection
end