pub struct LoadBalancer { /* private fields */ }Expand description
Load balancer for distributing traffic across cluster nodes [AIR-3][AIS-3][PFM-3][SCL-3][RES-3]
Implementations§
Source§impl LoadBalancer
impl LoadBalancer
Sourcepub fn new(config: &HighAvailabilityConfig) -> Self
pub fn new(config: &HighAvailabilityConfig) -> Self
Creates a new load balancer with the specified configuration
Sourcepub async fn initialize(&mut self) -> Result<(), HaError>
pub async fn initialize(&mut self) -> Result<(), HaError>
Initializes the load balancer
Sourcepub async fn select_node(
&self,
session_id: Option<&str>,
) -> Result<LoadBalancingResult, HaError>
pub async fn select_node( &self, session_id: Option<&str>, ) -> Result<LoadBalancingResult, HaError>
Selects the best node for a request
Sourcepub async fn add_node(&self, node: LoadBalancerNode) -> Result<(), HaError>
pub async fn add_node(&self, node: LoadBalancerNode) -> Result<(), HaError>
Adds a node to the load balancer
Sourcepub async fn remove_node(&self, node_id: &str) -> Result<(), HaError>
pub async fn remove_node(&self, node_id: &str) -> Result<(), HaError>
Removes a node from the load balancer
Sourcepub async fn update_node_health(
&self,
node_id: &str,
health_status: HealthState,
) -> Result<(), HaError>
pub async fn update_node_health( &self, node_id: &str, health_status: HealthState, ) -> Result<(), HaError>
Updates node health status
Sourcepub async fn record_request_completion(
&self,
node_id: &str,
response_time: Duration,
success: bool,
) -> Result<(), HaError>
pub async fn record_request_completion( &self, node_id: &str, response_time: Duration, success: bool, ) -> Result<(), HaError>
Records request completion for a node
Sourcepub async fn update_config(
&mut self,
config: &HighAvailabilityConfig,
) -> Result<(), HaError>
pub async fn update_config( &mut self, config: &HighAvailabilityConfig, ) -> Result<(), HaError>
Updates the load balancer configuration
Sourcepub async fn get_metrics(&self) -> LoadBalancerMetrics
pub async fn get_metrics(&self) -> LoadBalancerMetrics
Gets current load balancer metrics
Sourcepub async fn get_nodes(&self) -> HashMap<String, LoadBalancerNode>
pub async fn get_nodes(&self) -> HashMap<String, LoadBalancerNode>
Gets current node information
Sourcepub async fn is_enabled(&self) -> bool
pub async fn is_enabled(&self) -> bool
Checks if the load balancer is enabled
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more