Module: ActiveRecord::Turntable::ActiveRecordExt::ConnectionHandlerExtension
- Defined in:
- lib/active_record/turntable/active_record_ext/connection_handler_extension.rb
Instance Method Summary collapse
Instance Method Details
#retrieve_connection_pool(spec_name) ⇒ Object
Note:
Override not to establish_connection destroy existing connection pool proxy object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/active_record/turntable/active_record_ext/connection_handler_extension.rb', line 5 def retrieve_connection_pool(spec_name) owner_to_pool.fetch(spec_name) do # Check if a connection was previously established in an ancestor process, # which may have been forked. if ancestor_pool = pool_from_any_process_for(spec_name) if ancestor_pool.is_a?(ActiveRecord::ConnectionAdapters::ConnectionPool) # A connection was established in an ancestor process that must have # subsequently forked. We can't reuse the connection, but we can copy # the specification and establish a new connection with it. spec = ancestor_pool.spec spec = spec.to_hash if spec.respond_to?(:to_hash) establish_connection(spec).tap do |pool| pool.schema_cache = ancestor_pool.schema_cache if ancestor_pool.schema_cache end else # Use same PoolProxy object owner_to_pool[spec_name] = ancestor_pool end else owner_to_pool[spec_name] = nil end end end |