pub struct Backend {
pub addr: SocketAddr,
/* private fields */
}Expand description
Per-backend state with atomic connection counting and health tracking.
Fields§
§addr: SocketAddrThe network address of this backend.
Implementations§
Source§impl Backend
impl Backend
Sourcepub fn new(addr: SocketAddr) -> Self
pub fn new(addr: SocketAddr) -> Self
Create a new backend that starts healthy with zero active connections.
Sourcepub fn track_connection(self: &Arc<Self>) -> ConnectionGuard
pub fn track_connection(self: &Arc<Self>) -> ConnectionGuard
Increment the active connection count and return an RAII guard that decrements it on drop.
Sourcepub fn active_connections(&self) -> u64
pub fn active_connections(&self) -> u64
Current number of in-flight connections.
Sourcepub fn is_healthy(&self) -> bool
pub fn is_healthy(&self) -> bool
Returns true if the backend is currently marked healthy.
§Panics
Panics if the health RwLock is poisoned.
Sourcepub fn set_healthy(&self)
pub fn set_healthy(&self)
Sourcepub fn set_unhealthy(&self)
pub fn set_unhealthy(&self)
Sourcepub fn record_failure(&self)
pub fn record_failure(&self)
Record one consecutive health-check failure.
Sourcepub fn reset_failures(&self)
pub fn reset_failures(&self)
Reset the consecutive failure counter to zero.
Sourcepub fn consecutive_failures(&self) -> u64
pub fn consecutive_failures(&self) -> u64
Number of consecutive health-check failures.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Backend
impl RefUnwindSafe for Backend
impl Send for Backend
impl Sync for Backend
impl Unpin for Backend
impl UnsafeUnpin for Backend
impl UnwindSafe for Backend
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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