Class: ActiveRecord::ConnectionAdapters::LegacyPoolManager
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::LegacyPoolManager
- Defined in:
- lib/active_record/connection_adapters/legacy_pool_manager.rb
Overview
:nodoc:
Instance Method Summary collapse
- #get_pool_config(_, shard) ⇒ Object
-
#initialize ⇒ LegacyPoolManager
constructor
A new instance of LegacyPoolManager.
- #pool_configs(_ = nil) ⇒ Object
- #remove_pool_config(_, shard) ⇒ Object
- #set_pool_config(role, shard, pool_config) ⇒ Object
- #shard_names ⇒ Object
Constructor Details
#initialize ⇒ LegacyPoolManager
Returns a new instance of LegacyPoolManager.
6 7 8 |
# File 'lib/active_record/connection_adapters/legacy_pool_manager.rb', line 6 def initialize @name_to_pool_config = {} end |
Instance Method Details
#get_pool_config(_, shard) ⇒ Object
22 23 24 |
# File 'lib/active_record/connection_adapters/legacy_pool_manager.rb', line 22 def get_pool_config(_, shard) @name_to_pool_config[shard] end |
#pool_configs(_ = nil) ⇒ Object
14 15 16 |
# File 'lib/active_record/connection_adapters/legacy_pool_manager.rb', line 14 def pool_configs(_ = nil) @name_to_pool_config.values end |
#remove_pool_config(_, shard) ⇒ Object
18 19 20 |
# File 'lib/active_record/connection_adapters/legacy_pool_manager.rb', line 18 def remove_pool_config(_, shard) @name_to_pool_config.delete(shard) end |
#set_pool_config(role, shard, pool_config) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/active_record/connection_adapters/legacy_pool_manager.rb', line 26 def set_pool_config(role, shard, pool_config) if pool_config @name_to_pool_config[shard] = pool_config else raise ArgumentError, "The `pool_config` for the :#{role} role and :#{shard} shard was `nil`. Please check your configuration. If you want your writing role to be something other than `:writing` set `config.active_record.writing_role` in your application configuration. The same setting should be applied for the `reading_role` if applicable." end end |
#shard_names ⇒ Object
10 11 12 |
# File 'lib/active_record/connection_adapters/legacy_pool_manager.rb', line 10 def shard_names @name_to_pool_config.keys end |