|
lintel 0.2.0
|
#include <ConnectionPoolRegistry.h>
Public Member Functions | |
| void | registerPool (std::string name, std::shared_ptr< ConnectionPool > pool) |
| std::shared_ptr< ConnectionPool > | poolOf (const std::string &name) const |
| bool | hasPool (const std::string &name) const |
| void | clear () |
| bool | empty () const |
| std::size_t | size () const |
| std::vector< std::string > | names () const |
Static Public Member Functions | |
| static ConnectionPoolRegistry & | instance () |
Process-wide registry of named connection pools.
The pattern mirrors lintel::ReadinessRegistry: a process-wide singleton that components from different layers (persistence plugins, features) fill during startup and that the layers needing a pool read by the connection name. It is deliberately not a DI registration: the container resolves by type, not by name, so several pools could not be addressed.
The registry never creates a pool implicitly. Only DatabaseBootstrapPlugin registers pools, and only for a configured DatabaseConnectionEntry with poolSize > 0. A process without database entries (e.g. the worker using cfg/bootstrap_worker.xml) therefore has an empty registry, and poolOf() throws PoolNotFoundException instead of falling back to a lazily created default pool.
Thread safety: every method may be called from any thread.
| void lintel::db::ConnectionPoolRegistry::clear | ( | ) |
Remove every registered pool (used by tests).
| bool lintel::db::ConnectionPoolRegistry::empty | ( | ) | const |
| name | the connection name |
name
|
static |
| std::vector< std::string > lintel::db::ConnectionPoolRegistry::names | ( | ) | const |
| std::shared_ptr< ConnectionPool > lintel::db::ConnectionPoolRegistry::poolOf | ( | const std::string & | name | ) | const |
Look up a pool by name.
| name | the connection name |
| PoolNotFoundException | if no pool is registered under name |
| void lintel::db::ConnectionPoolRegistry::registerPool | ( | std::string | name, |
| std::shared_ptr< ConnectionPool > | pool | ||
| ) |
Register a pool; an existing pool of the same name is replaced.
| name | name the pool is reachable under (the connection name) |
| pool | the pool to register |
| std::size_t lintel::db::ConnectionPoolRegistry::size | ( | ) | const |