lintel 0.2.0
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
lintel::db::ConnectionPoolRegistry Class Reference

#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 ()
 

Detailed Description

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.

Member Function Documentation

◆ clear()

void lintel::db::ConnectionPoolRegistry::clear ( )

Remove every registered pool (used by tests).

◆ empty()

bool lintel::db::ConnectionPoolRegistry::empty ( ) const
Returns
true when no pool is registered

◆ hasPool()

bool lintel::db::ConnectionPoolRegistry::hasPool ( const std::string &  name) const
Parameters
namethe connection name
Returns
true when a pool is registered under name

◆ instance()

static ConnectionPoolRegistry & lintel::db::ConnectionPoolRegistry::instance ( )
static
Returns
the process-wide registry instance

◆ names()

std::vector< std::string > lintel::db::ConnectionPoolRegistry::names ( ) const
Returns
the registered names in alphabetical order (for tests and diagnostics)

◆ poolOf()

std::shared_ptr< ConnectionPool > lintel::db::ConnectionPoolRegistry::poolOf ( const std::string &  name) const

Look up a pool by name.

Parameters
namethe connection name
Returns
the registered pool
Exceptions
PoolNotFoundExceptionif no pool is registered under name

◆ registerPool()

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.

Parameters
namename the pool is reachable under (the connection name)
poolthe pool to register

◆ size()

std::size_t lintel::db::ConnectionPoolRegistry::size ( ) const
Returns
the number of registered pools

The documentation for this class was generated from the following file: