Sha256: 6ee7b1452e0be0b0effaa5a566570015ccc95a585acacf11136958768a7225f7

Contents?: true

Size: 984 Bytes

Versions: 1

Compression:

Stored size: 984 Bytes

Contents

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

      included do
        alias_method_chain :pool_for, :turntable
      end

      private

      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::Turntable::PoolProxy)
              # Use same PoolProxy object
              owner_to_pool[owner.name] = ancestor_pool
            else
              # 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
            end
          else
            owner_to_pool[owner.name] = nil
          end
        }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activerecord-turntable-2.0.0.rc1 lib/active_record/turntable/active_record_ext/connection_handler_extension.rb