pub struct ElectionHandler<T: TypeConfig> { /* private fields */ }Implementations§
Trait Implementations§
Source§impl<T: Clone + TypeConfig> Clone for ElectionHandler<T>
impl<T: Clone + TypeConfig> Clone for ElectionHandler<T>
Source§fn clone(&self) -> ElectionHandler<T>
fn clone(&self) -> ElectionHandler<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: TypeConfig> Debug for ElectionHandler<T>
impl<T: TypeConfig> Debug for ElectionHandler<T>
Source§impl<T> ElectionCore<T> for ElectionHandler<T>where
T: TypeConfig,
impl<T> ElectionCore<T> for ElectionHandler<T>where
T: TypeConfig,
Source§fn check_vote_request_is_legal(
&self,
request: &VoteRequest,
current_term: u64,
last_log_index: u64,
last_log_term: u64,
voted_for_option: Option<VotedFor>,
) -> bool
fn check_vote_request_is_legal( &self, request: &VoteRequest, current_term: u64, last_log_index: u64, last_log_term: u64, voted_for_option: Option<VotedFor>, ) -> bool
The function to check RPC request is leagal or not
Criterias to check:
- votedFor is null or candidateId
- candidate s log is at least as up-to-date as receiver s log e.g. { my_id: 2 } request=VoteRequest { term: 3, candidate_id: 1, last_log_index: 2, last_log_term: 10 } current_term=3 last_log_index=3 last_log_term=8 voted_for_option=None
Source§fn broadcast_vote_requests<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
term: u64,
membership: Arc<MOF<T>>,
raft_log: &'life1 Arc<ROF<T>>,
transport: &'life2 Arc<TROF<T>>,
settings: &'life3 Arc<RaftNodeConfig>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn broadcast_vote_requests<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
term: u64,
membership: Arc<MOF<T>>,
raft_log: &'life1 Arc<ROF<T>>,
transport: &'life2 Arc<TROF<T>>,
settings: &'life3 Arc<RaftNodeConfig>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Sends vote requests to all voting members. Returns Ok() if majority
votes are received, otherwise returns Err. Initiates RPC calls via
transport and evaluates collected responses. Read more
Source§fn handle_vote_request<'life0, 'life1, 'async_trait>(
&'life0 self,
request: VoteRequest,
current_term: u64,
voted_for_option: Option<VotedFor>,
raft_log: &'life1 Arc<ROF<T>>,
) -> Pin<Box<dyn Future<Output = Result<StateUpdate>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn handle_vote_request<'life0, 'life1, 'async_trait>(
&'life0 self,
request: VoteRequest,
current_term: u64,
voted_for_option: Option<VotedFor>,
raft_log: &'life1 Arc<ROF<T>>,
) -> Pin<Box<dyn Future<Output = Result<StateUpdate>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Processes incoming vote requests: validates request legality via
check_vote_request_is_legal, updates node state if valid, triggers
role transition to Follower when granting vote. Read more
Auto Trait Implementations§
impl<T> Freeze for ElectionHandler<T>
impl<T> RefUnwindSafe for ElectionHandler<T>where
T: RefUnwindSafe,
impl<T> Send for ElectionHandler<T>
impl<T> Sync for ElectionHandler<T>
impl<T> Unpin for ElectionHandler<T>where
T: Unpin,
impl<T> UnwindSafe for ElectionHandler<T>where
T: 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
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request