Class: ActiveRecord::ConnectionAdapters::PoolConfig
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::PoolConfig
- Includes:
- Mutex_m
- Defined in:
- lib/active_record/connection_adapters/pool_config.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#connection_class ⇒ Object
Returns the value of attribute connection_class.
-
#db_config ⇒ Object
readonly
Returns the value of attribute db_config.
-
#role ⇒ Object
readonly
Returns the value of attribute role.
- #schema_reflection ⇒ Object
-
#shard ⇒ Object
readonly
Returns the value of attribute shard.
Class Method Summary collapse
Instance Method Summary collapse
- #connection_name ⇒ Object
- #discard_pool! ⇒ Object
- #disconnect!(automatic_reconnect: false) ⇒ Object
-
#initialize(connection_class, db_config, role, shard) ⇒ PoolConfig
constructor
A new instance of PoolConfig.
- #pool ⇒ Object
Constructor Details
#initialize(connection_class, db_config, role, shard) ⇒ PoolConfig
Returns a new instance of PoolConfig.
29 30 31 32 33 34 35 36 37 |
# File 'lib/active_record/connection_adapters/pool_config.rb', line 29 def initialize(connection_class, db_config, role, shard) super() @connection_class = connection_class @db_config = db_config @role = role @shard = shard @pool = nil INSTANCES[self] = self end |
Instance Attribute Details
#connection_class ⇒ Object
Returns the value of attribute connection_class.
10 11 12 |
# File 'lib/active_record/connection_adapters/pool_config.rb', line 10 def connection_class @connection_class end |
#db_config ⇒ Object (readonly)
Returns the value of attribute db_config.
8 9 10 |
# File 'lib/active_record/connection_adapters/pool_config.rb', line 8 def db_config @db_config end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
8 9 10 |
# File 'lib/active_record/connection_adapters/pool_config.rb', line 8 def role @role end |
#schema_reflection ⇒ Object
12 13 14 |
# File 'lib/active_record/connection_adapters/pool_config.rb', line 12 def schema_reflection @schema_reflection ||= SchemaReflection.new(db_config.lazy_schema_cache_path) end |
#shard ⇒ Object (readonly)
Returns the value of attribute shard.
8 9 10 |
# File 'lib/active_record/connection_adapters/pool_config.rb', line 8 def shard @shard end |
Class Method Details
.discard_pools! ⇒ Object
20 21 22 |
# File 'lib/active_record/connection_adapters/pool_config.rb', line 20 def discard_pools! INSTANCES.each_key(&:discard_pool!) end |
.disconnect_all! ⇒ Object
24 25 26 |
# File 'lib/active_record/connection_adapters/pool_config.rb', line 24 def disconnect_all! INSTANCES.each_key { |c| c.disconnect!(automatic_reconnect: true) } end |
Instance Method Details
#connection_name ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/active_record/connection_adapters/pool_config.rb', line 39 def connection_name if connection_class.primary_class? "ActiveRecord::Base" else connection_class.name end end |
#discard_pool! ⇒ Object
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/active_record/connection_adapters/pool_config.rb', line 68 def discard_pool! return unless @pool synchronize do return unless @pool @pool.discard! @pool = nil end end |
#disconnect!(automatic_reconnect: false) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/active_record/connection_adapters/pool_config.rb', line 47 def disconnect!(automatic_reconnect: false) ActiveSupport::ForkTracker.check! return unless @pool synchronize do return unless @pool @pool.automatic_reconnect = automatic_reconnect @pool.disconnect! end nil end |
#pool ⇒ Object
62 63 64 65 66 |
# File 'lib/active_record/connection_adapters/pool_config.rb', line 62 def pool ActiveSupport::ForkTracker.check! @pool || synchronize { @pool ||= ConnectionAdapters::ConnectionPool.new(self) } end |