pub struct Node {
pub raft: Raft,
/* private fields */
}Expand description
A running node. The store holds one and sends every replicated write through it
Fields§
§raft: RaftImplementations§
Source§impl Node
impl Node
Sourcepub async fn write(&self, req: Request) -> Result<Reply>
pub async fn write(&self, req: Request) -> Result<Reply>
Propose on this node, or forward to the leader when this node follows. During an election the leader can be unknown or stale, so it waits and tries again, but only a write that was certainly not applied is sent again
Sourcepub fn is_leader(&self) -> bool
pub fn is_leader(&self) -> bool
The node that runs the leader’s phases. A node that stopped applying never does
Sourcepub async fn ensure_majority(&self) -> Result<()>
pub async fn ensure_majority(&self) -> Result<()>
Confirm with a heartbeat to the voters that this node still leads a majority. A leader cut off from the others gets an error here, so it sends nothing to GitHub
Sourcepub fn has_leader(&self) -> bool
pub fn has_leader(&self) -> bool
True while this node knows a leader, itself or another. A node cut off from the voters loses it once it starts an election
Sourcepub fn version(&self) -> Option<Version>
pub fn version(&self) -> Option<Version>
The version this node stamps on its writes. None on a single node
Sourcepub fn needs_upgrade(&self) -> Option<Version>
pub fn needs_upgrade(&self) -> Option<Version>
The version this node needs before it applies again, or None while it applies
Sourcepub fn highest_peer_version(&self) -> Option<Version>
pub fn highest_peer_version(&self) -> Option<Version>
The highest version a peer that proved the secret reported
Sourcepub fn versions(&self) -> &Arc<Versions> ⓘ
pub fn versions(&self) -> &Arc<Versions> ⓘ
What this node knows about versions, shared with its listener
Sourcepub fn term(&self) -> u64
pub fn term(&self) -> u64
The Raft term this node is in. A leader stamps it on every assignment
Sourcepub fn accept_assignment(&self, term: u64) -> bool
pub fn accept_assignment(&self, term: u64) -> bool
Fence a worker against an old leader: once this node started an assignment from one term, it starts none from an older term
pub async fn stop(self)
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Node
impl !UnwindSafe for Node
impl Forget for Node
impl Freeze for Nodewhere
*const ArcInner<RaftInner<TypeConfig>> is !null: Freeze,
PhantomData<ArcInner<RaftInner<TypeConfig>>>: Freeze,
*const ArcInner<str> is !null: Freeze,
PhantomData<ArcInner<str>>: Freeze,
*const ArcInner<Notify> is !null: Freeze,
PhantomData<ArcInner<Notify>>: Freeze,
*const ArcInner<Versions> is !null: Freeze,
PhantomData<ArcInner<Versions>>: Freeze,
*const ArcInner<Atomic<u64>> is !null: Freeze,
PhantomData<ArcInner<Atomic<u64>>>: Freeze,
impl Move for Node
impl Send for Node
impl Sync for Node
impl Unpin for Node
impl UnsafeUnpin for Nodewhere
*const ArcInner<RaftInner<TypeConfig>> is !null: UnsafeUnpin,
PhantomData<ArcInner<RaftInner<TypeConfig>>>: UnsafeUnpin,
*const ArcInner<str> is !null: UnsafeUnpin,
PhantomData<ArcInner<str>>: UnsafeUnpin,
*const ArcInner<Notify> is !null: UnsafeUnpin,
PhantomData<ArcInner<Notify>>: UnsafeUnpin,
*const ArcInner<Versions> is !null: UnsafeUnpin,
PhantomData<ArcInner<Versions>>: UnsafeUnpin,
*const ArcInner<Atomic<u64>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Atomic<u64>>>: UnsafeUnpin,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
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> ⓘ
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