Module: ActiveRecord::Materialized::ConnectionRouting Private
- Defined in:
- lib/activerecord/materialized/connection_routing.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Routes work to a Rails multi-database role when the app has configured one: maintenance writes to the primary, verification reads to a replica (the verify-on-replica / repair-on-primary split). A nil role — the default — yields on the current connection, so single-database apps and those relying on Rails' automatic role switching are unaffected.
Class Method Summary collapse
- .maintenance(&block) ⇒ Object private
- .verification(&block) ⇒ Object private
- .with_role(role, &block) ⇒ Object private
Class Method Details
.maintenance(&block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
14 15 16 |
# File 'lib/activerecord/materialized/connection_routing.rb', line 14 def maintenance(&block) with_role(ActiveRecord::Materialized.configuration.maintenance_role, &block) end |
.verification(&block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
18 19 20 |
# File 'lib/activerecord/materialized/connection_routing.rb', line 18 def verification(&block) with_role(ActiveRecord::Materialized.configuration.verification_role, &block) end |
.with_role(role, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
22 23 24 25 26 |
# File 'lib/activerecord/materialized/connection_routing.rb', line 22 def with_role(role, &block) return yield if role.nil? ActiveRecord::Base.connected_to(role: role, &block) end |