pub struct PoolRegistry<K, T> { /* private fields */ }Expand description
Hands out one ConnectionPool per key, built on first use. It is lazy: a pool is
created on first access and is NOT opened, so it does no background maintenance unless you
open it yourself.
Implementations§
Source§impl<K, T> PoolRegistry<K, T>
impl<K, T> PoolRegistry<K, T>
Sourcepub fn new<F>(factory_for: F, config: PoolConfig) -> Self
pub fn new<F>(factory_for: F, config: PoolConfig) -> Self
Builds a registry. factory_for makes the factory for a given key; config is shared by
every pool.
Sourcepub fn with_clock(self, clock: Arc<dyn Clock>) -> Self
pub fn with_clock(self, clock: Arc<dyn Clock>) -> Self
Shares clock with every pool the registry creates.
Sourcepub fn with_listeners(self, listeners: Vec<Arc<dyn PoolListener<T>>>) -> Self
pub fn with_listeners(self, listeners: Vec<Arc<dyn PoolListener<T>>>) -> Self
Shares listeners with every pool the registry creates.
Sourcepub fn pool(&self, key: &K) -> Result<ConnectionPool<T>, PoolError>
pub fn pool(&self, key: &K) -> Result<ConnectionPool<T>, PoolError>
Returns the pool for key, creating it on first use. The returned pool is a cheap handle
to the registry-owned pool.
Auto Trait Implementations§
impl<K, T> !Freeze for PoolRegistry<K, T>
impl<K, T> !RefUnwindSafe for PoolRegistry<K, T>
impl<K, T> !UnwindSafe for PoolRegistry<K, T>
impl<K, T> Send for PoolRegistry<K, T>
impl<K, T> Sync for PoolRegistry<K, T>
impl<K, T> Unpin for PoolRegistry<K, T>
impl<K, T> UnsafeUnpin for PoolRegistry<K, T>where
Box<dyn Fn(&K) -> Box<dyn ConnectionFactory<T>> + Send + Sync>: UnsafeUnpin,
Vec<Arc<dyn PoolListener<T>>>: UnsafeUnpin,
Mutex<RegState<K, T>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more