Replica

Struct Replica 

Source
pub struct Replica<S>
where S: Service,
{ /* private fields */ }
Expand description

A replica may perform the role of a primary or backup depending on the configuration and the current view. Implements a message-based viewstamped replication revisited protocol that does not wait for messages to arrive. Instead, the protocol requires returned messages to be re-queued for later (i.e. after a new message comes in).

Implementations§

Source§

impl<S> Replica<S>
where S: Service,

Source

pub fn new(configuration: Configuration, index: usize, service: S) -> Self

Creates a new instance of a replica.

Source

pub fn recovering<O>( configuration: Configuration, index: usize, checkpoint: Checkpoint<S::Checkpoint>, outbox: &mut O, ) -> Self
where O: Outbox<S>,

Creates a new instance of a replica running the recovery protocol. The caller is responsible for determining when a replica needs to recover.

Source

pub fn configuration(&self) -> Configuration

Source

pub fn index(&self) -> usize

Source

pub fn view(&self) -> View

Source

pub fn checkpoint(&self) -> Checkpoint<S::Checkpoint>

Source

pub fn checkpoint_with_suffix( &mut self, suffix: usize, ) -> Option<Checkpoint<S::Checkpoint>>

Source

pub fn idle<O>(&mut self, outbox: &mut O)
where O: Outbox<S>,

Source

pub fn resend_pending<O>(&mut self, outbox: &mut O)
where O: Outbox<S>,

Source

pub fn handle_request<O>( &mut self, request: Request<S::Request>, outbox: &mut O, )
where O: Outbox<S>,

Source

pub fn handle_prepare<M>( &mut self, message: Prepare<S::Request, S::Prediction>, mailbox: &mut M, )
where M: Mailbox<S>,

Source

pub fn handle_prepare_ok<M>(&mut self, message: PrepareOk, mailbox: &mut M)
where M: Mailbox<S>,

Source

pub fn handle_commit<M>(&mut self, message: Commit, mailbox: &mut M)
where M: Mailbox<S>,

Source

pub fn handle_get_state<M>(&mut self, message: GetState, mailbox: &mut M)
where M: Mailbox<S>,

Source

pub fn handle_recovery<O>(&mut self, message: Recovery, outbox: &mut O)
where O: Outbox<S>,

Source

pub fn handle_recovery_response<O>( &mut self, message: RecoveryResponse<S::Request, S::Prediction>, outbox: &mut O, )
where O: Outbox<S>,

Source

pub fn handle_new_state<O>( &mut self, message: NewState<S::Request, S::Prediction>, outbox: &mut O, )
where O: Outbox<S>,

Source

pub fn handle_start_view_change<O>( &mut self, message: StartViewChange, outbox: &mut O, )
where O: Outbox<S>,

Source

pub fn handle_do_view_change<O>( &mut self, message: DoViewChange<S::Request, S::Prediction>, outbox: &mut O, )
where O: Outbox<S>,

Source

pub fn handle_start_view<O>( &mut self, message: StartView<S::Request, S::Prediction>, outbox: &mut O, )
where O: Outbox<S>,

Source

pub fn is_primary(&self) -> bool

Source

pub fn is_backup(&self) -> bool

Auto Trait Implementations§

§

impl<S> Freeze for Replica<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for Replica<S>

§

impl<S> Send for Replica<S>
where S: Send, <S as Protocol>::Prediction: Send, <S as Protocol>::Request: Send, <S as Protocol>::Reply: Send,

§

impl<S> Sync for Replica<S>
where S: Sync, <S as Protocol>::Prediction: Sync, <S as Protocol>::Request: Sync, <S as Protocol>::Reply: Sync,

§

impl<S> Unpin for Replica<S>
where S: Unpin, <S as Protocol>::Prediction: Unpin, <S as Protocol>::Request: Unpin, <S as Protocol>::Reply: Unpin,

§

impl<S> UnwindSafe for Replica<S>

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.
Source§

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

Source§

fn vzip(self) -> V