123456789_123456789_123456789_123456789_123456789_

Class: ActiveRecord::ConnectionAdapters::PoolConfig

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
self, MonitorMixin
Inherits: Object
Defined in: activerecord/lib/active_record/connection_adapters/pool_config.rb

Constant Summary

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(connection_class, db_config, role, shard) ⇒ PoolConfig

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/pool_config.rb', line 29

def initialize(connection_class, db_config, role, shard)
  super()
  @server_version = nil
  @connection_class = connection_class
  @db_config = db_config
  @role = role
  @shard = shard
  @pool = nil
  INSTANCES[self] = self
end

Class Method Details

.discard_pools!

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/pool_config.rb', line 20

def discard_pools!
  INSTANCES.each_key(&:discard_pool!)
end

.disconnect_all!

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/pool_config.rb', line 24

def disconnect_all!
  INSTANCES.each_key { |c| c.disconnect!(automatic_reconnect: true) }
end

Instance Attribute Details

#connection_class (rw)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/pool_config.rb', line 10

attr_accessor :connection_class

#db_config (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/pool_config.rb', line 8

attr_reader :db_config, :role, :shard

#role (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/pool_config.rb', line 8

attr_reader :db_config, :role, :shard

#schema_reflection (rw)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/pool_config.rb', line 12

def schema_reflection
  @schema_reflection ||= SchemaReflection.new(db_config.lazy_schema_cache_path)
end

#schema_reflection=(value) (rw)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/pool_config.rb', line 9

attr_writer :schema_reflection, :server_version

#server_version(connection) (rw)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/pool_config.rb', line 40

def server_version(connection)
  @server_version || synchronize { @server_version ||= connection.get_database_version }
end

#server_version=(value) (rw)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/pool_config.rb', line 9

attr_writer :schema_reflection, :server_version

#shard (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/pool_config.rb', line 8

attr_reader :db_config, :role, :shard

Instance Method Details

#connection_name

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/pool_config.rb', line 44

def connection_name
  if connection_class.primary_class?
    "ActiveRecord::Base"
  else
    connection_class.name
  end
end

#discard_pool!

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/pool_config.rb', line 69

def discard_pool!
  return unless @pool

  synchronize do
    return unless @pool

    @pool.discard!
    @pool = nil
  end
end

#disconnect!(automatic_reconnect: false)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/pool_config.rb', line 52

def disconnect!(automatic_reconnect: false)
  return unless @pool

  synchronize do
    return unless @pool

    @pool.automatic_reconnect = automatic_reconnect
    @pool.disconnect!
  end

  nil
end

#pool

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/pool_config.rb', line 65

def pool
  @pool || synchronize { @pool ||= ConnectionAdapters::ConnectionPool.new(self) }
end