pub struct ReplicaSet { /* private fields */ }Expand description
Manages a set of replicas
Implementations§
Source§impl ReplicaSet
impl ReplicaSet
Sourcepub fn add_replica(
&mut self,
id: impl Into<String>,
address: impl Into<String>,
role: ReplicaRole,
) -> Result<()>
pub fn add_replica( &mut self, id: impl Into<String>, address: impl Into<String>, role: ReplicaRole, ) -> Result<()>
Add a replica to the set
Sourcepub fn remove_replica(&mut self, id: &str) -> Result<()>
pub fn remove_replica(&mut self, id: &str) -> Result<()>
Remove a replica from the set
Sourcepub fn get_replica(&self, id: &str) -> Option<Replica>
pub fn get_replica(&self, id: &str) -> Option<Replica>
Get a replica by ID
Sourcepub fn get_primary(&self) -> Option<Replica>
pub fn get_primary(&self) -> Option<Replica>
Get the current primary replica
Sourcepub fn get_secondaries(&self) -> Vec<Replica>
pub fn get_secondaries(&self) -> Vec<Replica>
Get all secondary replicas
Sourcepub fn get_healthy_replicas(&self) -> Vec<Replica>
pub fn get_healthy_replicas(&self) -> Vec<Replica>
Get all healthy replicas
Sourcepub fn promote_to_primary(&mut self, id: &str) -> Result<()>
pub fn promote_to_primary(&mut self, id: &str) -> Result<()>
Promote a secondary to primary
Sourcepub fn demote_to_secondary(&mut self, id: &str) -> Result<()>
pub fn demote_to_secondary(&mut self, id: &str) -> Result<()>
Demote a primary to secondary
Sourcepub fn has_quorum(&self) -> bool
pub fn has_quorum(&self) -> bool
Check if quorum is available
Sourcepub fn get_quorum_size(&self) -> usize
pub fn get_quorum_size(&self) -> usize
Get the required quorum size
Sourcepub fn set_quorum_size(&self, size: usize)
pub fn set_quorum_size(&self, size: usize)
Set the quorum size
Sourcepub fn replica_ids(&self) -> Vec<String>
pub fn replica_ids(&self) -> Vec<String>
Get all replica IDs
Sourcepub fn replica_count(&self) -> usize
pub fn replica_count(&self) -> usize
Get replica count
Sourcepub fn cluster_id(&self) -> &str
pub fn cluster_id(&self) -> &str
Get the cluster ID
Auto Trait Implementations§
impl Freeze for ReplicaSet
impl !RefUnwindSafe for ReplicaSet
impl Send for ReplicaSet
impl Sync for ReplicaSet
impl Unpin for ReplicaSet
impl !UnwindSafe for ReplicaSet
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