pub struct ReplicaManager { /* private fields */ }Expand description
Manager for replica placement and lifecycle
Implementations§
Source§impl ReplicaManager
impl ReplicaManager
Sourcepub fn new(config: ReplicationConfig) -> Self
pub fn new(config: ReplicationConfig) -> Self
Create a new replica manager
Sourcepub fn register_node(&self, topology: NodeTopology)
pub fn register_node(&self, topology: NodeTopology)
Register a node with its topology
Sourcepub fn deregister_node(&self, node_id: &str)
pub fn deregister_node(&self, node_id: &str)
Remove a node from available nodes
Sourcepub fn create_replica_set(
&self,
shard_id: &str,
replication_factor: Option<u32>,
) -> Result<ReplicaSet, ReplicationError>
pub fn create_replica_set( &self, shard_id: &str, replication_factor: Option<u32>, ) -> Result<ReplicaSet, ReplicationError>
Create a new replica set for a shard
Sourcepub fn get_replica_set(&self, shard_id: &str) -> Option<ReplicaSet>
pub fn get_replica_set(&self, shard_id: &str) -> Option<ReplicaSet>
Get replica set for a shard
Sourcepub fn update_replica_state(
&self,
shard_id: &str,
node_id: &str,
state: ReplicaState,
lag_ms: Option<u64>,
) -> Result<(), ReplicationError>
pub fn update_replica_state( &self, shard_id: &str, node_id: &str, state: ReplicaState, lag_ms: Option<u64>, ) -> Result<(), ReplicationError>
Update replica state
Sourcepub fn record_replica_failure(
&self,
shard_id: &str,
node_id: &str,
) -> Result<(), ReplicationError>
pub fn record_replica_failure( &self, shard_id: &str, node_id: &str, ) -> Result<(), ReplicationError>
Record a replica failure
Sourcepub fn promote_replica(
&self,
shard_id: &str,
new_primary_node: &str,
) -> Result<(), ReplicationError>
pub fn promote_replica( &self, shard_id: &str, new_primary_node: &str, ) -> Result<(), ReplicationError>
Promote a replica to primary
Sourcepub fn add_replica(
&self,
shard_id: &str,
node_id: &str,
) -> Result<(), ReplicationError>
pub fn add_replica( &self, shard_id: &str, node_id: &str, ) -> Result<(), ReplicationError>
Add a new replica to a shard
Sourcepub fn remove_replica(
&self,
shard_id: &str,
node_id: &str,
) -> Result<(), ReplicationError>
pub fn remove_replica( &self, shard_id: &str, node_id: &str, ) -> Result<(), ReplicationError>
Remove a replica from a shard
Sourcepub fn check_under_replicated(&self) -> Vec<(String, usize)>
pub fn check_under_replicated(&self) -> Vec<(String, usize)>
Get nodes that need replicas (automatic failover check)
Sourcepub fn auto_failover(
&self,
shard_id: &str,
) -> Result<Option<String>, ReplicationError>
pub fn auto_failover( &self, shard_id: &str, ) -> Result<Option<String>, ReplicationError>
Auto-failover: promote replica if primary is down
Sourcepub fn get_stats(&self) -> ReplicationStats
pub fn get_stats(&self) -> ReplicationStats
Get replication statistics
Sourcepub fn config(&self) -> &ReplicationConfig
pub fn config(&self) -> &ReplicationConfig
Get configuration
Auto Trait Implementations§
impl Freeze for ReplicaManager
impl !RefUnwindSafe for ReplicaManager
impl Send for ReplicaManager
impl Sync for ReplicaManager
impl Unpin for ReplicaManager
impl UnsafeUnpin for ReplicaManager
impl !UnwindSafe for ReplicaManager
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