LoadBalancer

Trait LoadBalancer 

Source
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 { ... }
}
Expand description

Load balancer trait for different algorithms

Required Methods§

Source

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

Source

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,

Report target health status

Source

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,

Get all healthy targets

Provided Methods§

Source

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)

Source

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)

Implementors§