def read_only_connection(pool_connection)
return pool_connection.master_connection if pool_connection.using_master_connection?
connection_type = Thread.current[:read_only_connection]
if connection_type.kind_of?(Hash)
connection = connection_type[pool_connection]
unless connection
connection = pool_connection.random_read_connection
connection_type[pool_connection] = connection
end
return connection
elsif connection_type == :random
return pool_connection.random_read_connection
else
return pool_connection.master_connection
end
end