pub struct BackendGroup {
pub backends: Vec<Arc<Backend>>,
pub strategy: LbStrategy,
/* private fields */
}Expand description
A set of backends for a single service, with a configured selection strategy.
Fields§
§backends: Vec<Arc<Backend>>The backends in this group.
strategy: LbStrategyThe strategy used by select.
Implementations§
Source§impl BackendGroup
impl BackendGroup
Sourcepub fn new(strategy: LbStrategy) -> Self
pub fn new(strategy: LbStrategy) -> Self
Create an empty group with the given strategy.
Sourcepub fn select(&self) -> Option<Arc<Backend>>
pub fn select(&self) -> Option<Arc<Backend>>
Select a healthy backend using the configured strategy.
Returns None if every backend is unhealthy (or the group is empty).
Sourcepub fn update_backends(&mut self, addrs: Vec<SocketAddr>)
pub fn update_backends(&mut self, addrs: Vec<SocketAddr>)
Replace the backend list while preserving state for addresses that remain unchanged.
Backends whose address appears in addrs keep their existing
connection counts, health status, and failure counters. New addresses
get a fresh Backend. Addresses no longer in addrs are dropped.
Sourcepub fn add_backend(&mut self, addr: SocketAddr)
pub fn add_backend(&mut self, addr: SocketAddr)
Add a backend if its address is not already present.
Sourcepub fn remove_backend(&mut self, addr: &SocketAddr)
pub fn remove_backend(&mut self, addr: &SocketAddr)
Remove the backend with the given address, if present.
Auto Trait Implementations§
impl !Freeze for BackendGroup
impl RefUnwindSafe for BackendGroup
impl Send for BackendGroup
impl Sync for BackendGroup
impl Unpin for BackendGroup
impl UnsafeUnpin for BackendGroup
impl UnwindSafe for BackendGroup
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