pub struct StreamService {
pub name: String,
pub backends: Vec<SocketAddr>,
/* private fields */
}Expand description
A resolved stream service with backend addresses and health state
Fields§
§name: StringService name (for logging/metrics)
backends: Vec<SocketAddr>Backend addresses for load balancing
Implementations§
Source§impl StreamService
impl StreamService
Sourcepub fn new(name: String, backends: Vec<SocketAddr>) -> Self
pub fn new(name: String, backends: Vec<SocketAddr>) -> Self
Create a new stream service
Sourcepub fn select_backend(&self) -> Option<SocketAddr>
pub fn select_backend(&self) -> Option<SocketAddr>
Select next backend using round-robin, skipping unhealthy backends.
Tries up to backends.len() candidates. If all backends are unhealthy,
falls back to returning any backend (better than nothing).
Sourcepub fn update_backends(&mut self, backends: Vec<SocketAddr>)
pub fn update_backends(&mut self, backends: Vec<SocketAddr>)
Update backend addresses (for scaling events).
New backends start with Unknown health; removed backends are pruned
from the health map.
Sourcepub async fn set_backend_health(&self, addr: SocketAddr, status: BackendHealth)
pub async fn set_backend_health(&self, addr: SocketAddr, status: BackendHealth)
Set the health status of a specific backend
Sourcepub async fn get_backend_health(&self, addr: SocketAddr) -> BackendHealth
pub async fn get_backend_health(&self, addr: SocketAddr) -> BackendHealth
Get the health status of a specific backend
Sourcepub fn backend_count(&self) -> usize
pub fn backend_count(&self) -> usize
Get current backend count
Sourcepub async fn healthy_count(&self) -> usize
pub async fn healthy_count(&self) -> usize
Get count of healthy (usable) backends
Trait Implementations§
Source§impl Clone for StreamService
impl Clone for StreamService
Source§fn clone(&self) -> StreamService
fn clone(&self) -> StreamService
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for StreamService
impl !RefUnwindSafe for StreamService
impl Send for StreamService
impl Sync for StreamService
impl Unpin for StreamService
impl UnsafeUnpin for StreamService
impl !UnwindSafe for StreamService
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