instance method
prepopulate
Ruby on Rails 8.1.2
Since v8.1.2Signature
prepopulate()
Ensure that the pool contains at least the configured minimum number of connections.
Source
# File activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb, line 776
def prepopulate
need_new_connections = nil
synchronize do
return if self.discarded?
# We don't want to start prepopulating until we know the pool is wanted,
# so we can avoid maintaining full pools in one-off scripts etc.
return unless @activated
need_new_connections = @connections.size < @min_connections
end
if need_new_connections
while new_conn = try_to_checkout_new_connection { @connections.size < @min_connections }
new_conn.allow_preconnect = true
checkin(new_conn)
end
end
end
Defined in activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb line 776
· View on GitHub
· Improve this page
· Find usages on GitHub