class Mongo::Server::Populator

A manager that maintains the invariant that the size of a connection pool is at least minPoolSize.

@api private

Attributes

options[R]

Public Class Methods

new(pool, options = {}) click to toggle source

@param [ Server::ConnectionPool ] The connection pool. @param [ Hash ] options The options.

@option options [ Logger ] :logger A custom logger to use.

# File lib/mongo/server/connection_pool/populator.rb, line 28
def initialize(pool, options = {})
  @pool = pool
  @thread = nil
  @options = options
end

Public Instance Methods

pre_stop() click to toggle source
# File lib/mongo/server/connection_pool/populator.rb, line 36
def pre_stop
  @pool.populate_semaphore.signal
end

Private Instance Methods

do_work() click to toggle source
# File lib/mongo/server/connection_pool/populator.rb, line 42
def do_work
  throw(:done) if @pool.closed?

  begin
    unless @pool.populate
      @pool.populate_semaphore.wait
    end
  rescue Error::AuthError, Error => e
    # Errors encountered when trying to add connections to
    # pool; try again later
    log_warn("Populator failed to connect a connection for #{@pool.address}: #{e.class}: #{e}.")
    @pool.populate_semaphore.wait(5)
  end
end