use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum QueryStrategy {
Fifo,
Smart,
RoundRobin,
}
impl QueryStrategy {
pub fn description(&self) -> &'static str {
match self {
Self::Fifo => "按配置顺序依次查询,适合有明确优先级的场景",
Self::Smart => "基于性能指标智能选择,适合追求最优性能的场景",
Self::RoundRobin => "轮流使用不同服务器,适合负载均衡场景",
}
}
pub fn requires_metrics(&self) -> bool {
matches!(self, Self::Smart)
}
pub fn supports_concurrent(&self) -> bool {
matches!(self, Self::Fifo | Self::Smart)
}
}