pub struct ReplicationLagMonitor { /* private fields */ }Expand description
复制延迟监控器
维护每个 slave 的最新延迟快照,提供基于延迟的路由决策。
Implementations§
Source§impl ReplicationLagMonitor
impl ReplicationLagMonitor
Sourcepub fn with_max_history(self, max: usize) -> Self
pub fn with_max_history(self, max: usize) -> Self
设置最大历史保留条数
Sourcepub fn latest_lag(&self, slave: &str) -> Option<u64>
pub fn latest_lag(&self, slave: &str) -> Option<u64>
获取 slave 的最新延迟
Sourcepub fn is_lagging(&self, slave: &str) -> bool
pub fn is_lagging(&self, slave: &str) -> bool
判断 slave 是否延迟过大
Sourcepub fn is_safe_to_read(&self, slave: &str) -> bool
pub fn is_safe_to_read(&self, slave: &str) -> bool
判断 slave 是否可以安全读取
Sourcepub fn lagging_slaves(&self) -> Vec<String>
pub fn lagging_slaves(&self) -> Vec<String>
返回所有延迟过大的 slave
Sourcepub fn safe_slaves(&self) -> Vec<String>
pub fn safe_slaves(&self) -> Vec<String>
返回所有安全可读的 slave
Sourcepub fn history(&self, slave: &str) -> Vec<ReplicationLagSnapshot>
pub fn history(&self, slave: &str) -> Vec<ReplicationLagSnapshot>
获取 slave 的延迟历史
Sourcepub fn select_least_lag<'a>(&self, candidates: &'a [String]) -> Option<&'a str>
pub fn select_least_lag<'a>(&self, candidates: &'a [String]) -> Option<&'a str>
从候选列表中选择延迟最小的 slave
返回 None 表示候选列表为空或无延迟数据。
Sourcepub fn all_slaves(&self) -> Vec<String>
pub fn all_slaves(&self) -> Vec<String>
返回所有已知 slave 列表
Sourcepub fn slave_count(&self) -> usize
pub fn slave_count(&self) -> usize
已知 slave 数量
Auto Trait Implementations§
impl !Freeze for ReplicationLagMonitor
impl RefUnwindSafe for ReplicationLagMonitor
impl Send for ReplicationLagMonitor
impl Sync for ReplicationLagMonitor
impl Unpin for ReplicationLagMonitor
impl UnsafeUnpin for ReplicationLagMonitor
impl UnwindSafe for ReplicationLagMonitor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more