Module: MariaDbClusterPool
- Defined in:
- lib/maria_db_cluster_pool.rb,
lib/maria_db_cluster_pool/connect_timeout.rb
Overview
This module allows setting the read pool connection type. Generally you will use one of
- use_random_connection
- use_persistent_read_connection
- use_master_connection
Each of these methods can take an optional block. If they are called with a block, they will set the read connection type only within the block. Otherwise they will set the default read connection type. If none is ever called, the read connection type will be :master.
Defined Under Namespace
Modules: ConnectTimeout
Constant Summary collapse
- ADAPTER_TO_CLASS_NAME_MAP =
Adapter name to class name map. This exists because there isn’t an obvious way to translate things like sqlite3 to SQLite3. The adapters that ship with ActiveRecord are defined here. If you use an adapter that doesn’t translate directly to camel case, then add the mapping here in an initializer.
{"sqlite" => "SQLite", "sqlite3" => "SQLite3", "postgresql" => "PostgreSQL"}
Class Method Summary collapse
-
.adapter_class_for(name) ⇒ Object
Get the connection adapter class for an adapter name.
Class Method Details
.adapter_class_for(name) ⇒ Object
Get the connection adapter class for an adapter name. The class will be loaded from ActiveRecord::ConnectionAdapters::NameAdapter where Name is the camelized version of the name. If the adapter class does not fit this pattern (i.e. sqlite3 => SQLite3Adapter), then add the mapping to the ADAPTER_TO_CLASS_NAME_MAP
Hash.
124 125 126 127 128 |
# File 'lib/maria_db_cluster_pool.rb', line 124 def adapter_class_for(name) name = name.to_s class_name = ADAPTER_TO_CLASS_NAME_MAP[name] || name.camelize "ActiveRecord::ConnectionAdapters::#{class_name}Adapter".constantize end |