pub struct LoadBalancer { /* private fields */ }Expand description
Load balancer
Implementations§
Source§impl LoadBalancer
impl LoadBalancer
Sourcepub fn new(strategy: LoadBalancingStrategy) -> Self
pub fn new(strategy: LoadBalancingStrategy) -> Self
Create new load balancer with strategy
Sourcepub fn add_endpoint(&self, endpoint: BackendEndpoint)
pub fn add_endpoint(&self, endpoint: BackendEndpoint)
Add backend endpoint
Sourcepub fn remove_endpoint(&self, id: &str) -> bool
pub fn remove_endpoint(&self, id: &str) -> bool
Remove endpoint by ID
Sourcepub fn get_endpoint(&self, id: &str) -> Option<BackendEndpoint>
pub fn get_endpoint(&self, id: &str) -> Option<BackendEndpoint>
Get endpoint by ID
Sourcepub fn set_endpoint_health(&self, id: &str, healthy: bool)
pub fn set_endpoint_health(&self, id: &str, healthy: bool)
Mark endpoint as healthy/unhealthy
Sourcepub fn get_endpoints(&self) -> Vec<BackendEndpoint>
pub fn get_endpoints(&self) -> Vec<BackendEndpoint>
Get all endpoints
Sourcepub fn get_healthy_endpoints(&self) -> Vec<BackendEndpoint>
pub fn get_healthy_endpoints(&self) -> Vec<BackendEndpoint>
Get healthy endpoints only
Sourcepub fn select(&self) -> Result<BackendEndpoint>
pub fn select(&self) -> Result<BackendEndpoint>
Select next endpoint based on strategy
Sourcepub fn get_stats(&self) -> LoadBalancerStats
pub fn get_stats(&self) -> LoadBalancerStats
Get load balancer statistics
Auto Trait Implementations§
impl Freeze for LoadBalancer
impl !RefUnwindSafe for LoadBalancer
impl Send for LoadBalancer
impl Sync for LoadBalancer
impl Unpin for LoadBalancer
impl !UnwindSafe for LoadBalancer
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
Mutably borrows from an owned value. Read more