pub struct LagMonitor { /* private fields */ }Expand description
Lag Monitor - tracks replication lag across all nodes
Implementations§
Source§impl LagMonitor
impl LagMonitor
Sourcepub fn new(config: LagRoutingConfig) -> Self
pub fn new(config: LagRoutingConfig) -> Self
Create a new lag monitor
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create with default config
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Check if monitoring is running
Sourcepub fn set_primary(&self, node_id: &str)
pub fn set_primary(&self, node_id: &str)
Set the primary node ID
Sourcepub fn get_primary(&self) -> Option<NodeId>
pub fn get_primary(&self) -> Option<NodeId>
Get the primary node ID
Sourcepub fn update_primary_lsn(&self, lsn: u64)
pub fn update_primary_lsn(&self, lsn: u64)
Update primary LSN
Sourcepub fn get_primary_lsn(&self) -> u64
pub fn get_primary_lsn(&self) -> u64
Get current primary LSN
Sourcepub fn register_standby(&self, node_id: &str, sync_mode: SyncMode)
pub fn register_standby(&self, node_id: &str, sync_mode: SyncMode)
Register a standby node
Sourcepub fn remove_node(&self, node_id: &str)
pub fn remove_node(&self, node_id: &str)
Remove a node from monitoring
Sourcepub fn update_standby_lag(
&self,
node_id: &str,
current_lsn: u64,
time_lag: Option<Duration>,
)
pub fn update_standby_lag( &self, node_id: &str, current_lsn: u64, time_lag: Option<Duration>, )
Update lag info for a standby node
Sourcepub fn get_all_lags(&self) -> Vec<(NodeId, LagInfo)>
pub fn get_all_lags(&self) -> Vec<(NodeId, LagInfo)>
Get all current lag info
Sourcepub fn get_fresh_nodes(&self, max_lag: Duration) -> Vec<NodeId> ⓘ
pub fn get_fresh_nodes(&self, max_lag: Duration) -> Vec<NodeId> ⓘ
Get nodes that meet freshness requirement
Sourcepub fn get_nodes_at_lsn(&self, required_lsn: u64) -> Vec<NodeId> ⓘ
pub fn get_nodes_at_lsn(&self, required_lsn: u64) -> Vec<NodeId> ⓘ
Get nodes that have reached a specific LSN
Sourcepub fn has_reached_lsn(&self, node_id: &str, required_lsn: u64) -> bool
pub fn has_reached_lsn(&self, node_id: &str, required_lsn: u64) -> bool
Check if a node has reached a specific LSN
Sourcepub fn get_healthy_nodes(&self) -> Vec<NodeId> ⓘ
pub fn get_healthy_nodes(&self) -> Vec<NodeId> ⓘ
Get healthy nodes (lag below stale threshold)
Sourcepub fn get_freshest_standby(&self) -> Option<(NodeId, LagInfo)>
pub fn get_freshest_standby(&self) -> Option<(NodeId, LagInfo)>
Get the freshest standby (lowest lag)
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Get node count
Source§impl LagMonitor
impl LagMonitor
Sourcepub fn arc(config: LagRoutingConfig) -> Arc<Self> ⓘ
pub fn arc(config: LagRoutingConfig) -> Arc<Self> ⓘ
Create an Arc-wrapped instance
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for LagMonitor
impl !RefUnwindSafe for LagMonitor
impl Send for LagMonitor
impl Sync for LagMonitor
impl Unpin for LagMonitor
impl UnsafeUnpin for LagMonitor
impl UnwindSafe for LagMonitor
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more