1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Deprecate config.threadsafe!

This commit is contained in:
José Valim 2012-08-01 21:10:55 +02:00
parent 2801786e1a
commit 5d416b9078
4 changed files with 22 additions and 24 deletions

View file

@ -87,6 +87,10 @@ end
* +config.dependency_loading+ is a flag that allows you to disable constant autoloading setting it to false. It only has effect if +config.cache_classes+ is true, which it is by default in production mode. This flag is set to false by +config.threadsafe!+.
* +config.eager_load+ when true, eager loads all registered `config.eager_load_namespaces`. This includes your application, engines, Rails frameworks and any other registered namespace.
* +config.eager_load_namespaces+ registers namespaces that are eager loaded when +config.eager_load+ is true. All namespaces in the list must respond to the +eager_load!+ method.
* +config.eager_load_paths+ accepts an array of paths from which Rails will eager load on boot if cache classes is enabled. Defaults to every folder in the +app+ directory of the application.
* +config.encoding+ sets up the application-wide encoding. Defaults to UTF-8.
@ -125,10 +129,6 @@ config.session_store :my_custom_store
This custom store must be defined as +ActionDispatch::Session::MyCustomStore+. In addition to symbols, they can also be objects implementing a certain API, like +ActiveRecord::SessionStore+, in which case no special namespace is required.
* +config.threadsafe!+ enables +cache_classes+ and +eager_load+ to make the application threadsafe.
WARNING: Threadsafe operation is incompatible with the normal workings of development mode Rails. In particular, automatic dependency loading and class reloading are automatically disabled when you call +config.threadsafe!+.
* +config.time_zone+ sets the default time zone for the application and enables time zone awareness for Active Record.
* +config.whiny_nils+ enables or disables warnings when a certain set of methods are invoked on +nil+ and it does not respond to them. Defaults to true in development and test environments.
@ -746,13 +746,13 @@ The error occurred while evaluating nil.each
*+build_middleware_stack+* Builds the middleware stack for the application, returning an object which has a +call+ method which takes a Rack environment object for the request.
*+eager_load!+* If +config.cache_classes+ is true, runs the +config.before_eager_load+ hooks and then calls +eager_load!+ which will load all the Ruby files from +config.eager_load_paths+.
*+eager_load!+* If +config.eager_load+ is true, runs the +config.before_eager_load+ hooks and then calls +eager_load!+ which will load all +config.eager_load_namespaces+.
*+finisher_hook+* Provides a hook for after the initialization of process of the application is complete, as well as running all the +config.after_initialize+ blocks for the application, railties and engines.
*+set_routes_reloader+* Configures Action Dispatch to reload the routes file using +ActionDispatch::Callbacks.to_prepare+.
*+disable_dependency_loading+* Disables the automatic dependency loading if the +config.cache_classes+ is set to true and +config.dependency_loading+ is set to false.
*+disable_dependency_loading+* Disables the automatic dependency loading if the +config.eager_load+ is set to true.
h3. Database pooling

View file

@ -5,6 +5,8 @@
default_url_options[:script_name] to set proper application's mount point by
yourself. *Piotr Sarnacki*
* `config.threadsafe!` is deprecated in favor of `config.eager_load` which provides a more fine grained control on what is eager loaded *José Valim*
* The migration generator will now produce AddXXXToYYY/RemoveXXXFromYYY migrations with references statements, for instance
rails g migration AddReferencesToProducts user:references supplier:references{polymorphic}

View file

@ -90,11 +90,10 @@ module Rails
end
end
# Enable threaded mode. Allows concurrent requests to controller actions and
# multiple database connections. Also disables automatic dependency loading
# after boot, and disables reloading code on every request, as these are
# fundamentally incompatible with thread safety.
def threadsafe!
ActiveSupport::Deprecation.warn "config.threadsafe! is deprecated. Rails applications " \
"behave by default as thread safe in production as long as config.cache_classes and " \
"config.eager_load are set to true"
@cache_classes = true
@eager_load = true
self

View file

@ -139,34 +139,31 @@ module ApplicationTests
assert_instance_of Pathname, Rails.root
end
test "marking the application as threadsafe sets the correct config variables" do
test "initialize an eager loaded, cache classes app" do
add_to_config <<-RUBY
config.threadsafe!
RUBY
require "#{app_path}/config/application"
assert AppTemplate::Application.config.cache_classes
assert AppTemplate::Application.config.eager_load
end
test "initialize a threadsafe app" do
add_to_config <<-RUBY
config.threadsafe!
config.eager_load = true
config.cache_classes = true
RUBY
require "#{app_path}/config/application"
assert AppTemplate::Application.initialize!
end
test "application is always added to eager_load namespaces" do
require "#{app_path}/config/application"
assert AppTemplate::Application, AppTemplate::Application.config.eager_load_namespaces
end
test "asset_path defaults to nil for application" do
require "#{app_path}/config/environment"
assert_equal nil, AppTemplate::Application.config.asset_path
end
test "the application can be marked as threadsafe when there are no frameworks" do
test "the application can be eager loaded even when there are no frameworks" do
FileUtils.rm_rf("#{app_path}/config/environments")
add_to_config <<-RUBY
config.threadsafe!
config.eager_load = true
config.cache_classes = true
RUBY
use_frameworks []