class ActiveRecord::ConnectionAdapters::ConnectionHandler

def retrieve_connection(spec_name, role: ActiveRecord::Base.current_role, shard: ActiveRecord::Base.current_shard) # :nodoc:

Experimental RBS support (using type sampling data from the type_fusion project).

def retrieve_connection: (String spec_name, role: Symbol, shard: Symbol) -> (ActiveRecord::ConnectionAdapters::PostgreSQLAdapter | ActiveRecord::ConnectionAdapters::SQLite3Adapter)

This signature was generated using 69 samples from 2 applications.

:nodoc:
for (not necessarily the current class).
opened and set as the active connection for the class it was defined
active or defined connection: if it is the latter, it will be
Locate the connection of the nearest super class. This can be an
def retrieve_connection(spec_name, role: ActiveRecord::Base.current_role, shard: ActiveRecord::Base.current_shard) # :nodoc:
  pool = retrieve_connection_pool(spec_name, role: role, shard: shard)
  unless pool
    if shard != ActiveRecord::Base.default_shard
      message = "No connection pool for '#{spec_name}' found for the '#{shard}' shard."
    elsif ActiveRecord::Base.connection_handler != ActiveRecord::Base.default_connection_handler
      message = "No connection pool for '#{spec_name}' found for the '#{ActiveRecord::Base.current_role}' role."
    elsif role != ActiveRecord::Base.default_role
      message = "No connection pool for '#{spec_name}' found for the '#{role}' role."
    else
      message = "No connection pool for '#{spec_name}' found."
    end
    raise ConnectionNotEstablished, message
  end
  pool.connection
end