pub trait LoadBalancer: Send + Sync {
// Required methods
fn select<'life0, 'life1, 'async_trait>(
&'life0 self,
context: Option<&'life1 RequestContext>,
) -> Pin<Box<dyn Future<Output = SentinelResult<TargetSelection>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn report_health<'life0, 'life1, 'async_trait>(
&'life0 self,
address: &'life1 str,
healthy: bool,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn healthy_targets<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn release<'life0, 'life1, 'async_trait>(
&'life0 self,
_selection: &'life1 TargetSelection,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn report_result<'life0, 'life1, 'async_trait>(
&'life0 self,
_selection: &'life1 TargetSelection,
_success: bool,
_latency: Option<Duration>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn report_result_with_latency<'life0, 'life1, 'async_trait>(
&'life0 self,
address: &'life1 str,
success: bool,
_latency: Option<Duration>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
Load balancer trait for different algorithms
Required Methods§
Sourcefn select<'life0, 'life1, 'async_trait>(
&'life0 self,
context: Option<&'life1 RequestContext>,
) -> Pin<Box<dyn Future<Output = SentinelResult<TargetSelection>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn select<'life0, 'life1, 'async_trait>(
&'life0 self,
context: Option<&'life1 RequestContext>,
) -> Pin<Box<dyn Future<Output = SentinelResult<TargetSelection>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Select next upstream target
Provided Methods§
Sourcefn release<'life0, 'life1, 'async_trait>(
&'life0 self,
_selection: &'life1 TargetSelection,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn release<'life0, 'life1, 'async_trait>(
&'life0 self,
_selection: &'life1 TargetSelection,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Release connection (for connection tracking)
Sourcefn report_result<'life0, 'life1, 'async_trait>(
&'life0 self,
_selection: &'life1 TargetSelection,
_success: bool,
_latency: Option<Duration>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn report_result<'life0, 'life1, 'async_trait>(
&'life0 self,
_selection: &'life1 TargetSelection,
_success: bool,
_latency: Option<Duration>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Report request result (for adaptive algorithms)
Sourcefn report_result_with_latency<'life0, 'life1, 'async_trait>(
&'life0 self,
address: &'life1 str,
success: bool,
_latency: Option<Duration>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn report_result_with_latency<'life0, 'life1, 'async_trait>(
&'life0 self,
address: &'life1 str,
success: bool,
_latency: Option<Duration>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Report request result by address with latency (for adaptive algorithms)
This method allows reporting results without needing the full TargetSelection, which is useful when the selection is not available (e.g., in logging callback). The default implementation just calls report_health; adaptive balancers override this to update their metrics.