pub struct Replica {
pub id: String,
pub address: String,
pub role: ReplicaRole,
pub status: ReplicaStatus,
pub lag_ms: u64,
pub log_position: u64,
pub last_heartbeat: DateTime<Utc>,
pub priority: u32,
}Expand description
Represents a single replica in the replication topology
Fields§
§id: StringUnique identifier for the replica
address: StringNetwork address of the replica
role: ReplicaRoleCurrent role of the replica
status: ReplicaStatusCurrent status of the replica
lag_ms: u64Replication lag in milliseconds
log_position: u64Last known position in the replication log
last_heartbeat: DateTime<Utc>Last heartbeat timestamp
priority: u32Priority for failover (higher is better)
Implementations§
Source§impl Replica
impl Replica
Sourcepub fn new(
id: impl Into<String>,
address: impl Into<String>,
role: ReplicaRole,
) -> Self
pub fn new( id: impl Into<String>, address: impl Into<String>, role: ReplicaRole, ) -> Self
Create a new replica
Sourcepub fn is_healthy(&self) -> bool
pub fn is_healthy(&self) -> bool
Check if the replica is healthy
Sourcepub fn is_readable(&self) -> bool
pub fn is_readable(&self) -> bool
Check if the replica is available for reads
Sourcepub fn is_writable(&self) -> bool
pub fn is_writable(&self) -> bool
Check if the replica is available for writes
Sourcepub fn update_lag(&mut self, lag_ms: u64)
pub fn update_lag(&mut self, lag_ms: u64)
Update the replica’s lag
Sourcepub fn update_position(&mut self, position: u64)
pub fn update_position(&mut self, position: u64)
Update the replica’s log position
Sourcepub fn is_timed_out(&self, timeout: Duration) -> bool
pub fn is_timed_out(&self, timeout: Duration) -> bool
Check if the replica has timed out
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Replica
impl<'de> Deserialize<'de> for Replica
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Replica
impl RefUnwindSafe for Replica
impl Send for Replica
impl Sync for Replica
impl Unpin for Replica
impl UnwindSafe for Replica
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