pub struct AdaptiveConnectionPool { /* private fields */ }Implementations§
Source§impl AdaptiveConnectionPool
impl AdaptiveConnectionPool
pub async fn new(db: Arc<Database>, config: AdaptivePoolConfig) -> Result<Self>
pub async fn new_sync( db: Arc<Database>, config: AdaptivePoolConfig, ) -> Result<Self>
pub async fn check_and_scale(&self)
pub async fn get(&self) -> Result<AdaptivePooledConnection>
pub fn available_connections(&self) -> usize
pub fn utilization(&self) -> f64
pub fn active_connections(&self) -> u32
pub fn max_connections(&self) -> u32
pub fn metrics(&self) -> AdaptivePoolMetrics
Sourcepub fn set_cleanup_callback(&self, callback: ConnectionCleanupCallback)
pub fn set_cleanup_callback(&self, callback: ConnectionCleanupCallback)
Register a cleanup callback to be called when connections are dropped
This allows external components (like the prepared statement cache) to clean up resources when a connection is returned to the pool.
§Arguments
callback- Function to call with the connection ID when a connection is dropped
§Example
use std::sync::Arc;
use do_memory_storage_turso::pool::{AdaptiveConnectionPool, ConnectionId};
use do_memory_storage_turso::PreparedStatementCache;
let cache = Arc::new(PreparedStatementCache::new(100));
let cache_clone = Arc::clone(&cache);
pool.set_cleanup_callback(Arc::new(move |conn_id: ConnectionId| {
cache_clone.clear_connection(conn_id);
}));Sourcepub fn remove_cleanup_callback(&self)
pub fn remove_cleanup_callback(&self)
Remove the cleanup callback
This disables automatic cleanup notifications.
pub async fn shutdown(&self)
Auto Trait Implementations§
impl !Freeze for AdaptiveConnectionPool
impl !RefUnwindSafe for AdaptiveConnectionPool
impl Send for AdaptiveConnectionPool
impl Sync for AdaptiveConnectionPool
impl Unpin for AdaptiveConnectionPool
impl UnsafeUnpin for AdaptiveConnectionPool
impl !UnwindSafe for AdaptiveConnectionPool
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::RequestSource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.