pub enum Node {
Candidate(RawNode<Candidate>),
Follower(RawNode<Follower>),
Leader(RawNode<Leader>),
}Expand description
具有动态角色的 Raft 节点。
Variants§
Candidate(RawNode<Candidate>)
候选人(含 Pre-vote 相位)。
Follower(RawNode<Follower>)
跟随者。
Leader(RawNode<Leader>)
领导者。
Implementations§
Source§impl Node
impl Node
Sourcepub fn new(
id: NodeID,
peers: HashSet<NodeID>,
log: Log,
state: Box<dyn State>,
tx: Sender<Envelope>,
opts: Options,
) -> Result<Self>
pub fn new( id: NodeID, peers: HashSet<NodeID>, log: Log, state: Box<dyn State>, tx: Sender<Envelope>, opts: Options, ) -> Result<Self>
创建新的 Raft 节点。peers 为除自身外的初始投票同伴。
pub fn id(&self) -> NodeID
pub fn term(&self) -> Term
pub fn step(self, msg: Envelope) -> Result<Self>
pub fn tick(self) -> Result<Self>
Auto Trait Implementations§
impl !RefUnwindSafe for Node
impl !Sync for Node
impl !UnwindSafe for Node
impl Freeze for Node
impl Send for Node
impl Unpin for Node
impl UnsafeUnpin for Node
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