method
establish_connection
v6.1.7.7 -
Show latest stable
-
0 notes -
Class: ActiveRecord::ConnectionAdapters::ConnectionHandler
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1 (0)
- 2.3.8 (0)
- 3.0.0 (0)
- 3.0.9 (0)
- 3.1.0 (0)
- 3.2.1 (0)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2 (0)
- 4.1.8 (0)
- 4.2.1 (0)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (0)
- 5.1.7 (0)
- 5.2.3 (0)
- 6.0.0 (0)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (0)
- 7.1.3.4 (0)
- 7.2.3 (0)
- 8.0.0 (0)
- 8.1.1 (0)
- What's this?
establish_connection(config, owner_name: Base, role: ActiveRecord::Base.current_role, shard: Base.current_shard)
public
Hide source
# File activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb, line 1043 def establish_connection(config, owner_name: Base, role: ActiveRecord::Base.current_role, shard: Base.current_shard) owner_name = config.to_s if config.is_a?(Symbol) pool_config = resolve_pool_config(config, owner_name) db_config = pool_config.db_config # Protects the connection named `ActiveRecord::Base` from being removed # if the user calls `establish_connection :primary`. if owner_to_pool_manager.key?(pool_config.connection_specification_name) remove_connection_pool(pool_config.connection_specification_name, role: role, shard: shard) end message_bus = ActiveSupport::Notifications.instrumenter payload = {} if pool_config payload[:spec_name] = pool_config.connection_specification_name payload[:shard] = shard payload[:config] = db_config.configuration_hash end if ActiveRecord::Base.legacy_connection_handling owner_to_pool_manager[pool_config.connection_specification_name] ||= LegacyPoolManager.new else owner_to_pool_manager[pool_config.connection_specification_name] ||= PoolManager.new end pool_manager = get_pool_manager(pool_config.connection_specification_name) pool_manager.set_pool_config(role, shard, pool_config) message_bus.instrument("!connection.active_record", payload) do pool_config.pool end end

