pub struct Raft {
pub id: u64,
pub leading: Option<Leading>,
pub commit: u64,
pub net: Net,
pub sto: Store,
pub metrics: Sender<Metrics>,
pub rx: UnboundedReceiver<(u64, Event)>,
}
Fields§
§id: u64
§leading: Option<Leading>
§commit: u64
§net: Net
§sto: Store
§metrics: Sender<Metrics>
§rx: UnboundedReceiver<(u64, Event)>
Implementations§
Source§impl Raft
impl Raft
pub fn new( id: u64, sto: Store, net: Net, rx: UnboundedReceiver<(u64, Event)>, ) -> Self
pub async fn run(self) -> Result<(), Error>
pub fn elect(&mut self)
pub fn write(&mut self, tx: Sender<String>, log: Log) -> Option<LogId>
pub fn handle_replicate_req(&mut self, req: Request) -> Reply
pub fn handle_replicate_reply( &mut self, target: u64, reply: Reply, ) -> Option<Leading>
pub fn send_if_idle(&mut self, target: u64, n: u64) -> Option<()>
Auto Trait Implementations§
impl Freeze for Raft
impl !RefUnwindSafe for Raft
impl Send for Raft
impl Sync for Raft
impl Unpin for Raft
impl !UnwindSafe for Raft
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> 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