Sha256: 5a8aedb8f21443a136e4c09c136537c489f1c560a0f784c1c041fc4e7dc6a777

Contents?: true

Size: 1.07 KB

Versions: 17

Compression:

Stored size: 1.07 KB

Contents

module ActiveRecord::Turntable
  module ActiveRecordExt
    module ConnectionHandlerExtension
      extend ActiveSupport::Concern

      included do
        alias_method_chain :pool_for, :turntable
      end

      private

      # @note Override not to establish_connection destroy existing connection pool proxy object
      def pool_for_with_turntable(owner)
        owner_to_pool.fetch(owner.name) {
          if ancestor_pool = pool_from_any_process_for(owner)
            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.
              establish_connection owner, ancestor_pool.spec
            else
              # Use same PoolProxy object
              owner_to_pool[owner.name] = ancestor_pool
            end
          else
            owner_to_pool[owner.name] = nil
          end
        }
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
activerecord-turntable-2.5.0 lib/active_record/turntable/active_record_ext/connection_handler_extension.rb
activerecord-turntable-2.4.0 lib/active_record/turntable/active_record_ext/connection_handler_extension.rb
activerecord-turntable-2.3.3 lib/active_record/turntable/active_record_ext/connection_handler_extension.rb
activerecord-turntable-2.3.2 lib/active_record/turntable/active_record_ext/connection_handler_extension.rb
activerecord-turntable-2.3.1 lib/active_record/turntable/active_record_ext/connection_handler_extension.rb
activerecord-turntable-2.3.0 lib/active_record/turntable/active_record_ext/connection_handler_extension.rb
activerecord-turntable-2.2.2 lib/active_record/turntable/active_record_ext/connection_handler_extension.rb
activerecord-turntable-2.2.1 lib/active_record/turntable/active_record_ext/connection_handler_extension.rb
activerecord-turntable-2.2.0 lib/active_record/turntable/active_record_ext/connection_handler_extension.rb
activerecord-turntable-2.1.1 lib/active_record/turntable/active_record_ext/connection_handler_extension.rb
activerecord-turntable-2.1.0 lib/active_record/turntable/active_record_ext/connection_handler_extension.rb
activerecord-turntable-2.1.0.rc2 lib/active_record/turntable/active_record_ext/connection_handler_extension.rb
activerecord-turntable-2.1.0.rc1 lib/active_record/turntable/active_record_ext/connection_handler_extension.rb
activerecord-turntable-2.1.0.beta2 lib/active_record/turntable/active_record_ext/connection_handler_extension.rb
activerecord-turntable-2.1.0.beta1 lib/active_record/turntable/active_record_ext/connection_handler_extension.rb
activerecord-turntable-2.0.6 lib/active_record/turntable/active_record_ext/connection_handler_extension.rb
activerecord-turntable-2.0.5 lib/active_record/turntable/active_record_ext/connection_handler_extension.rb