module MariaDbClusterPool

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.

Constants

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.

Public Class Methods

adapter_class_for(name) click to toggle source

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.

# 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