Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finish rename of database_operations to database_resolver_context #35187

Merged
merged 2 commits into from
Feb 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions activerecord/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
```
config.active_record.database_selector = { delay: 2.seconds }
config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
config.active_record.database_operations = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
```

To change the database selection strategy, pass a custom class to the
Expand All @@ -38,7 +38,7 @@
```
config.active_record.database_selector = { delay: 10.seconds }
config.active_record.database_resolver = MyResolver
config.active_record.database_operations = MyResolver::MyCookies
config.active_record.database_resolver_context = MyResolver::MyCookies
```

*Eileen M. Uchitelle*
Expand Down
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class Railtie < Rails::Railtie # :nodoc:
initializer "active_record.database_selector" do
if options = config.active_record.delete(:database_selector)
resolver = config.active_record.delete(:database_resolver)
operations = config.active_record.delete(:database_operations)
operations = config.active_record.delete(:database_resolver_context)
config.app_middleware.use ActiveRecord::Middleware::DatabaseSelector, resolver, operations, options
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,16 @@ Rails.application.configure do
# The `database_resolver` class is used by the middleware to determine which
# database is appropriate to use based on the time delay.
#
# The `database_operations` class is used by the middleware to set timestamps
# for the last write to the primary. The resolver uses the operations class
# timestamps to determine how long to wait before reading from the replica.
# The `database_resolver_context` class is used by the middleware to set
# timestamps for the last write to the primary. The resolver uses the context
# class timestamps to determine how long to wait before reading from the
# replica.
#
# By default Rails will store a last write timestamp in the session. The
# DatabaseSelector middleware is designed as such you can define your own
# strategy for connection switching and pass that into the middleware through
# these configuration options.
# config.active_record.database_selector = { delay: 2.seconds }
# config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
# config.active_record.database_operations = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
# config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
end