pub struct ReplicationManager { /* private fields */ }Expand description
Replication Manager
Manages database replication across multiple nodes.
Implementations§
Source§impl ReplicationManager
impl ReplicationManager
Sourcepub fn new(node_id: String, config: ReplicationConfig) -> Self
pub fn new(node_id: String, config: ReplicationConfig) -> Self
Create a new Replication Manager with no transport configured.
Note: replicate_changes() on a manager built this way always
fails with TdbError::DistributedTransportNotConfigured — there is
no way to honestly ship changes to replicas without a transport. Use
ReplicationManager::with_transport (with a real network-backed
transport, or
crate::consensus::transport::LoopbackSimulationTransport for
single-node tests) to actually replicate.
Sourcepub fn with_transport(
node_id: String,
config: ReplicationConfig,
transport: Arc<dyn NetworkTransport>,
) -> Self
pub fn with_transport( node_id: String, config: ReplicationConfig, transport: Arc<dyn NetworkTransport>, ) -> Self
Create a new Replication Manager backed by a real (or
explicitly-simulated) NetworkTransport. This is the constructor
production code should use.
Sourcepub async fn add_replica(
&mut self,
node_id: String,
endpoint: String,
) -> Result<()>
pub async fn add_replica( &mut self, node_id: String, endpoint: String, ) -> Result<()>
Add a replica node
Sourcepub async fn remove_replica(&mut self, node_id: &str) -> Result<()>
pub async fn remove_replica(&mut self, node_id: &str) -> Result<()>
Remove a replica node
Sourcepub async fn promote_to_master(&mut self, node_id: &str) -> Result<()>
pub async fn promote_to_master(&mut self, node_id: &str) -> Result<()>
Promote a slave to master (failover)
Sourcepub async fn record_change(
&mut self,
txn_id: String,
data: Vec<u8>,
) -> Result<u64>
pub async fn record_change( &mut self, txn_id: String, data: Vec<u8>, ) -> Result<u64>
Record a change for replication
Sourcepub async fn replicate_changes(
&mut self,
changes: Vec<ReplicationChange>,
) -> Result<()>
pub async fn replicate_changes( &mut self, changes: Vec<ReplicationChange>, ) -> Result<()>
Replicate changes to all replicas
Sourcepub async fn check_replica_health(&self) -> Result<()>
pub async fn check_replica_health(&self) -> Result<()>
Check replica health and update status
Sourcepub async fn resolve_conflict(
&mut self,
change1: &ReplicationChange,
change2: &ReplicationChange,
) -> Result<ReplicationChange>
pub async fn resolve_conflict( &mut self, change1: &ReplicationChange, change2: &ReplicationChange, ) -> Result<ReplicationChange>
Handle conflict in master-master replication
Sourcepub async fn check_and_failover(&mut self) -> Result<bool>
pub async fn check_and_failover(&mut self) -> Result<bool>
Perform automatic failover if master is down
Sourcepub fn role(&self) -> ReplicaRole
pub fn role(&self) -> ReplicaRole
Get current role
Sourcepub fn stats(&self) -> ReplicationStats
pub fn stats(&self) -> ReplicationStats
Get statistics
Sourcepub fn replica_count(&self) -> usize
pub fn replica_count(&self) -> usize
Get replica count
Sourcepub fn healthy_replica_count(&self) -> usize
pub fn healthy_replica_count(&self) -> usize
Get healthy replica count
Sourcepub fn current_lsn(&self) -> u64
pub fn current_lsn(&self) -> u64
Get current LSN
Sourcepub fn change_buffer_size(&self) -> usize
pub fn change_buffer_size(&self) -> usize
Get change buffer size
Auto Trait Implementations§
impl !RefUnwindSafe for ReplicationManager
impl !UnwindSafe for ReplicationManager
impl Freeze for ReplicationManager
impl Send for ReplicationManager
impl Sync for ReplicationManager
impl Unpin for ReplicationManager
impl UnsafeUnpin for ReplicationManager
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> Fruit for T
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> ⓘ
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> ⓘ
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