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,
impl<S> Replica<S>where
S: Service,
Sourcepub fn new(configuration: Configuration, index: usize, service: S) -> Self
pub fn new(configuration: Configuration, index: usize, service: S) -> Self
Creates a new instance of a replica.
Sourcepub fn recovering<O>(
configuration: Configuration,
index: usize,
checkpoint: Checkpoint<S::Checkpoint>,
outbox: &mut O,
) -> Selfwhere
O: Outbox<S>,
pub fn recovering<O>(
configuration: Configuration,
index: usize,
checkpoint: Checkpoint<S::Checkpoint>,
outbox: &mut O,
) -> Selfwhere
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.
pub fn configuration(&self) -> Configuration
pub fn index(&self) -> usize
pub fn view(&self) -> View
pub fn checkpoint(&self) -> Checkpoint<S::Checkpoint>
pub fn checkpoint_with_suffix( &mut self, suffix: usize, ) -> Option<Checkpoint<S::Checkpoint>>
pub fn idle<O>(&mut self, outbox: &mut O)where
O: Outbox<S>,
pub fn resend_pending<O>(&mut self, outbox: &mut O)where
O: Outbox<S>,
pub fn handle_request<O>(
&mut self,
request: Request<S::Request>,
outbox: &mut O,
)where
O: Outbox<S>,
pub fn handle_prepare<M>(
&mut self,
message: Prepare<S::Request, S::Prediction>,
mailbox: &mut M,
)where
M: Mailbox<S>,
pub fn handle_prepare_ok<M>(&mut self, message: PrepareOk, mailbox: &mut M)where
M: Mailbox<S>,
pub fn handle_commit<M>(&mut self, message: Commit, mailbox: &mut M)where
M: Mailbox<S>,
pub fn handle_get_state<M>(&mut self, message: GetState, mailbox: &mut M)where
M: Mailbox<S>,
pub fn handle_recovery<O>(&mut self, message: Recovery, outbox: &mut O)where
O: Outbox<S>,
pub fn handle_recovery_response<O>(
&mut self,
message: RecoveryResponse<S::Request, S::Prediction>,
outbox: &mut O,
)where
O: Outbox<S>,
pub fn handle_new_state<O>(
&mut self,
message: NewState<S::Request, S::Prediction>,
outbox: &mut O,
)where
O: Outbox<S>,
pub fn handle_start_view_change<O>(
&mut self,
message: StartViewChange,
outbox: &mut O,
)where
O: Outbox<S>,
pub fn handle_do_view_change<O>(
&mut self,
message: DoViewChange<S::Request, S::Prediction>,
outbox: &mut O,
)where
O: Outbox<S>,
pub fn handle_start_view<O>(
&mut self,
message: StartView<S::Request, S::Prediction>,
outbox: &mut O,
)where
O: Outbox<S>,
pub fn is_primary(&self) -> bool
pub fn is_backup(&self) -> bool
Auto Trait Implementations§
impl<S> Freeze for Replica<S>where
S: Freeze,
impl<S> RefUnwindSafe for Replica<S>where
S: RefUnwindSafe,
<S as Protocol>::Prediction: RefUnwindSafe,
<S as Protocol>::Request: RefUnwindSafe,
<S as Protocol>::Reply: RefUnwindSafe,
impl<S> Send for Replica<S>
impl<S> Sync for Replica<S>
impl<S> Unpin for Replica<S>
impl<S> UnwindSafe for Replica<S>where
S: UnwindSafe,
<S as Protocol>::Prediction: UnwindSafe,
<S as Protocol>::Reply: UnwindSafe,
<S as Protocol>::Request: UnwindSafe,
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