LbStrategy

Trait LbStrategy 

Source
pub trait LbStrategy: Send + Sync {
    // Required methods
    fn strategy(&self) -> Strategy;
    fn contain(&self, addr: &Address) -> bool;
    fn add_backend(&self, addr: Address);
    fn remove_backend(&self, addr: &Address) -> bool;
    fn get_backend(&self, key: &str) -> Option<BackendState>;
    fn get_backends(&self) -> Vec<BackendState>;

    // Provided method
    fn backend<KEY: AsRef<str>>(
        this: Box<dyn LbStrategy>,
        key: KEY,
    ) -> Option<BackendState>
       where Self: Sized { ... }
}
Expand description

策略trait

Required Methods§

Source

fn strategy(&self) -> Strategy

策略类型

Source

fn contain(&self, addr: &Address) -> bool

判断一个后端地址是否存在

Source

fn add_backend(&self, addr: Address)

添加一个后端地址

Source

fn remove_backend(&self, addr: &Address) -> bool

移除一个后端地址

Source

fn get_backend(&self, key: &str) -> Option<BackendState>

获取一个后端地址

Source

fn get_backends(&self) -> Vec<BackendState>

获取所有后端地址

Provided Methods§

Source

fn backend<KEY: AsRef<str>>( this: Box<dyn LbStrategy>, key: KEY, ) -> Option<BackendState>
where Self: Sized,

获取一个后端地址, 通过通用key

Implementors§