pub struct ConnectionGuard { /* private fields */ }Expand description
RAII guard for pooled connections.
Automatically removes an unreleased connection from the pool on drop. Drop
applies replacement cooldown because unreleased guards represent unknown or
backend-error state. Use retire_without_cooldown for known client-side
dirty sockets that should not throttle backend replacement.
Follows the same pattern as CommandGuard from src/router/mod.rs.
Implementations§
Source§impl ConnectionGuard
impl ConnectionGuard
Sourcepub const fn new(
conn: Object<TcpManager>,
provider: DeadpoolConnectionProvider,
) -> Self
pub const fn new( conn: Object<TcpManager>, provider: DeadpoolConnectionProvider, ) -> Self
Create a new guard (removes from pool on drop unless released).
Sourcepub fn release(self) -> Object<TcpManager>
pub fn release(self) -> Object<TcpManager>
Return connection to pool (healthy).
Connection will be returned to the pool normally when the returned
Object is dropped. The guard is consumed — no cleanup happens.
§Panics
Panics if the guard has already been consumed (double-release).
Sourcepub fn retire_without_cooldown(self)
pub fn retire_without_cooldown(self)
Close and remove the connection without applying replacement cooldown.
Use this when the socket is dirty from a client-side abort, but the backend did not fail and should not have its pool capacity reduced.
§Panics
Panics if the guard has already been consumed.
Sourcepub fn retire_with_cooldown(self)
pub fn retire_with_cooldown(self)
Close and remove the connection, applying replacement cooldown.
Use this only when the backend connection itself failed or is known to be
in a backend-error state. Client-side disconnects and local dirty-socket
retirement should use retire_without_cooldown.
§Panics
Panics if the guard has already been consumed.
Sourcepub const fn get_mut(&mut self) -> &mut Object<TcpManager>
pub const fn get_mut(&mut self) -> &mut Object<TcpManager>
Sourcepub const fn get(&self) -> &Object<TcpManager>
pub const fn get(&self) -> &Object<TcpManager>
pub fn connection_type(&self) -> &'static str
pub fn pending_bytes_len(&self) -> usize
pub fn provider_status_counts(&self) -> DeadpoolStatusCounts
pub fn provider_name(&self) -> &str
Trait Implementations§
Source§impl Deref for ConnectionGuard
impl Deref for ConnectionGuard
Source§impl DerefMut for ConnectionGuard
impl DerefMut for ConnectionGuard
Source§impl Drop for ConnectionGuard
impl Drop for ConnectionGuard
Auto Trait Implementations§
impl !Freeze for ConnectionGuard
impl !RefUnwindSafe for ConnectionGuard
impl !UnwindSafe for ConnectionGuard
impl Send for ConnectionGuard
impl Sync for ConnectionGuard
impl Unpin for ConnectionGuard
impl UnsafeUnpin for ConnectionGuard
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
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> ⓘ
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> ⓘ
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 more