Returns the ConnectionPool instance associated with the current class and connection specification. The pool manages a finite set of reusable database connections, providing thread-safe checkout and checkin semantics.
pool_key (Symbol) — The key identifying which pool configuration to use. Defaults to the current handler's writing role.ConnectionPool — The active connection pool for this class.
ConnectionNotEstablished — If no pool configuration exists for the given pool key, or if establish_connection has not been called.
Think of the connection pool as a checkout counter at a library. Your application has a limited number of database connections available, and each thread needs to "check out" one before it can talk to the database.
This method gives you access to that checkout counter. It looks up the right pool for your model's configuration and hands it back. If no pool has been set up yet (i.e., you haven't called establish_connection), it raises an error to let you know.
Most of the time you won't call this directly — ActiveRecord handles it behind the scenes. But if you're debugging connection issues or building custom connection logic, this is your entry point.
Returns the ConnectionPool for this model. Raises ConnectionNotEstablished if unavailable.
establish_connection, connected?, remove_connection