Sha256: 62071bc4554f97f3c07fe317aec5aa034207108d51fee385a7a18c8e974e50fc
Contents?: true
Size: 1.47 KB
Versions: 2
Compression:
Stored size: 1.47 KB
Contents
# frozen_string_literal: true module ActiveRecord module ConnectionAdapters class PoolConfig # :nodoc: include Mutex_m attr_reader :db_config, :connection_klass attr_accessor :schema_cache INSTANCES = ObjectSpace::WeakMap.new private_constant :INSTANCES class << self def discard_pools! INSTANCES.each_key(&:discard_pool!) end end def initialize(connection_klass, db_config) super() @connection_klass = connection_klass @db_config = db_config @pool = nil INSTANCES[self] = self end def connection_specification_name if connection_klass.primary_class? "ActiveRecord::Base" else connection_klass.name end end def disconnect! ActiveSupport::ForkTracker.check! return unless @pool synchronize do return unless @pool @pool.automatic_reconnect = false @pool.disconnect! end nil end def pool ActiveSupport::ForkTracker.check! @pool || synchronize { @pool ||= ConnectionAdapters::ConnectionPool.new(self) } end def discard_pool! return unless @pool synchronize do return unless @pool @pool.discard! @pool = nil end end end end end ActiveSupport::ForkTracker.after_fork { ActiveRecord::ConnectionAdapters::PoolConfig.discard_pools! }
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
activerecord-7.0.0.alpha2 | lib/active_record/connection_adapters/pool_config.rb |
activerecord-7.0.0.alpha1 | lib/active_record/connection_adapters/pool_config.rb |