pub struct LoadBalancer { /* private fields */ }Expand description
Distributed load balancer
Implementations§
Source§impl LoadBalancer
impl LoadBalancer
Sourcepub fn new(config: LoadBalancerConfig) -> Self
pub fn new(config: LoadBalancerConfig) -> Self
Create a new load balancer
Sourcepub fn with_strategy(strategy: Strategy) -> Self
pub fn with_strategy(strategy: Strategy) -> Self
Create with default configuration
Sourcepub fn add_endpoint(&self, endpoint: Endpoint)
pub fn add_endpoint(&self, endpoint: Endpoint)
Add an endpoint
Sourcepub fn remove_endpoint(&self, node_id: &NodeId)
pub fn remove_endpoint(&self, node_id: &NodeId)
Remove an endpoint
Sourcepub fn update_health(&self, node_id: &NodeId, health: HealthStatus)
pub fn update_health(&self, node_id: &NodeId, health: HealthStatus)
Update endpoint health
Sourcepub fn update_metrics(&self, node_id: &NodeId, metrics: LoadMetrics)
pub fn update_metrics(&self, node_id: &NodeId, metrics: LoadMetrics)
Update endpoint metrics
Sourcepub fn select(
&self,
ctx: &RequestContext,
) -> Result<Selection, LoadBalancerError>
pub fn select( &self, ctx: &RequestContext, ) -> Result<Selection, LoadBalancerError>
Select an endpoint for a request.
The connection slot is reserved atomically as part of selection so
that concurrent selectors cannot collectively exceed
max_connections_per_endpoint. If a strategy picks an endpoint whose
cap was filled by a concurrent selector between availability filtering
and reservation, the selection is retried up to a bounded number of
times before giving up.
Sourcepub fn record_completion(&self, node_id: &NodeId, success: bool)
pub fn record_completion(&self, node_id: &NodeId, success: bool)
Record request completion
Sourcepub fn stats(&self) -> LoadBalancerStats
pub fn stats(&self) -> LoadBalancerStats
Get statistics
Sourcepub fn endpoint_count(&self) -> usize
pub fn endpoint_count(&self) -> usize
Get endpoint count
Auto Trait Implementations§
impl !Freeze for LoadBalancer
impl !RefUnwindSafe for LoadBalancer
impl Send for LoadBalancer
impl Sync for LoadBalancer
impl Unpin for LoadBalancer
impl UnsafeUnpin 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