pub trait Chooser: DynClone + Debug + Sync + Send {
fn choose(
&self,
ips: &[IpAddrWithPort],
opts: ChooseOptions<'_>
) -> ChosenResults;
fn feedback(&self, feedback: ChooserFeedback<'_>);
fn async_choose(
&'a self,
ips: &'a [IpAddrWithPort],
opts: ChooseOptions<'a>
) -> Pin<Box<dyn Future<Output = ChosenResults> + Send + 'a, Global>> { ... }
fn async_feedback(
&'a self,
feedback: ChooserFeedback<'a>
) -> Pin<Box<dyn Future<Output = ()> + Send + 'a, Global>> { ... }
}
Expand description
选择 IP 地址接口
还提供了对选择结果的反馈接口,用以修正自身选择逻辑,优化选择结果
同时提供阻塞接口和异步接口,异步接口则需要启用 async
功能
Required Methods
sourcefn choose(&self, ips: &[IpAddrWithPort], opts: ChooseOptions<'_>) -> ChosenResults
fn choose(&self, ips: &[IpAddrWithPort], opts: ChooseOptions<'_>) -> ChosenResults
选择 IP 地址列表
sourcefn feedback(&self, feedback: ChooserFeedback<'_>)
fn feedback(&self, feedback: ChooserFeedback<'_>)
反馈选择的 IP 地址列表的结果
Provided Methods
sourcefn async_choose(
&'a self,
ips: &'a [IpAddrWithPort],
opts: ChooseOptions<'a>
) -> Pin<Box<dyn Future<Output = ChosenResults> + Send + 'a, Global>>
fn async_choose(
&'a self,
ips: &'a [IpAddrWithPort],
opts: ChooseOptions<'a>
) -> Pin<Box<dyn Future<Output = ChosenResults> + Send + 'a, Global>>
异步选择 IP 地址列表
该方法的异步版本为 Self::async_choose
。
sourcefn async_feedback(
&'a self,
feedback: ChooserFeedback<'a>
) -> Pin<Box<dyn Future<Output = ()> + Send + 'a, Global>>
fn async_feedback(
&'a self,
feedback: ChooserFeedback<'a>
) -> Pin<Box<dyn Future<Output = ()> + Send + 'a, Global>>
异步反馈选择的 IP 地址列表的结果