pub struct StreamService {
pub name: String,
pub backends: Vec<SocketAddr>,
pub config: StreamProxyConfig,
/* 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
config: StreamProxyConfigRuntime L4 config (TLS / proxy-protocol / session-timeout / health probe)
translated from the endpoint’s stream: block. Drives the health
checker’s probe selection (see StreamRegistry::spawn_health_checker).
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 with_config(self, config: StreamProxyConfig) -> Self
pub fn with_config(self, config: StreamProxyConfig) -> Self
Attach a runtime StreamProxyConfig to this service.
Builder-style; preserves StreamService::new’s 2-arg arity so the
existing call sites keep compiling. The config’s health_check drives
what the background health checker probes.
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
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more