CausalCluster

Struct CausalCluster 

Source
pub struct CausalCluster<S: Lattice + Clone> {
    replicas: Vec<CausalReplica<S>>,
    network: CausalNetworkSimulator<S>,
}
Expand description

Cluster coordinator for causal anti-entropy

Fields§

§replicas: Vec<CausalReplica<S>>

All replicas

§network: CausalNetworkSimulator<S>

Network simulator

Implementations§

Source§

impl<S: Lattice + Clone> CausalCluster<S>

Source

pub fn new(n: usize, loss_rate: f64) -> Self

Create a new cluster with n replicas

Source

pub fn replica(&self, idx: usize) -> &CausalReplica<S>

Get replica by index

Source

pub fn replica_mut(&mut self, idx: usize) -> &mut CausalReplica<S>

Get mutable replica

Source

pub fn mutate<F>(&mut self, replica_idx: usize, mutator: F) -> S
where F: FnOnce(&S) -> S,

Perform a mutation

Source

pub fn broadcast_intervals(&mut self, from_idx: usize)

Initiate sync from one replica to all its peers

Source

pub fn process_one(&mut self) -> bool

Process one network message

Source

pub fn drain_network(&mut self)

Drain all messages

Source

pub fn full_sync_round(&mut self)

Full sync round

Source

pub fn is_converged(&self) -> bool

Check if converged

Source

pub fn retransmit_and_process(&mut self)

Retransmit and process

Source

pub fn len(&self) -> usize

Number of replicas

Source

pub fn is_empty(&self) -> bool

Check if empty

Source

pub fn crash_and_recover(&mut self, idx: usize)

Simulate a crash and recovery for a replica

Source

pub fn total_pending(&self) -> usize

Get total pending out-of-order intervals across all replicas

Trait Implementations§

Source§

impl<S: Debug + Lattice + Clone> Debug for CausalCluster<S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S> Freeze for CausalCluster<S>

§

impl<S> RefUnwindSafe for CausalCluster<S>
where S: RefUnwindSafe,

§

impl<S> Send for CausalCluster<S>
where S: Send,

§

impl<S> Sync for CausalCluster<S>
where S: Sync,

§

impl<S> Unpin for CausalCluster<S>
where S: Unpin,

§

impl<S> UnwindSafe for CausalCluster<S>
where S: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V