123456789_123456789_123456789_123456789_123456789_

Class: Mongo::Server::ConnectionPool::Populator Private

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
Inherits: Object
Defined in: lib/mongo/server/connection_pool/populator.rb

Overview

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

Since:

  • 2.0.0, largely rewritten in 2.9.0

Constant Summary

::Mongo::Loggable - Included

PREFIX

Class Method Summary

Instance Attribute Summary

::Mongo::BackgroundThread - Included

Instance Method Summary

::Mongo::BackgroundThread - Included

#run!

Start the background thread.

#stop!

Stop the background thread and wait for to terminate for a reasonable amount of time.

#do_work

Override this method to do the work in the background thread.

#pre_stop

Override this method to perform additional signaling for the background thread to stop.

#start!,
#wait_for_stop

Waits for the thread to die, with a timeout.

::Mongo::Loggable - Included

#log_debug

Convenience method to log debug messages with the standard prefix.

#log_error

Convenience method to log error messages with the standard prefix.

#log_fatal

Convenience method to log fatal messages with the standard prefix.

#log_info

Convenience method to log info messages with the standard prefix.

#log_warn

Convenience method to log warn messages with the standard prefix.

#logger

Get the logger instance.

#_mongo_log_prefix, #format_message

Instance Attribute Details

#options (readonly)

Since:

  • 2.0.0, largely rewritten in 2.9.0

[ GitHub ]

  
# File 'lib/mongo/server/connection_pool/populator.rb', line 38

attr_reader :options

Instance Method Details

#do_work (private)

Since:

  • 2.0.0, largely rewritten in 2.9.0

[ GitHub ]

  
# File 'lib/mongo/server/connection_pool/populator.rb', line 46

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

#pre_stop

Since:

  • 2.0.0, largely rewritten in 2.9.0

[ GitHub ]

  
# File 'lib/mongo/server/connection_pool/populator.rb', line 40

def pre_stop
  @pool.populate_semaphore.signal
end