pub struct MockElectionCore<T>where
T: TypeConfig,{ /* private fields */ }Implementations§
Source§impl<T> MockElectionCore<T>where
T: TypeConfig,
impl<T> MockElectionCore<T>where
T: TypeConfig,
Sourcepub fn checkpoint(&mut self)
pub fn checkpoint(&mut self)
Validate that all current expectations for all methods have been satisfied, and discard them.
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new mock object with no expectations.
This method will not be generated if the real struct
already has a new method. However, it will be
generated if the struct implements a trait with a new
method. The trait’s new method can still be called
like <MockX as TraitY>::new
Source§impl<T> MockElectionCore<T>where
T: TypeConfig,
impl<T> MockElectionCore<T>where
T: TypeConfig,
Sourcepub fn expect_broadcast_vote_requests(&mut self) -> &mut Expectation<T>
pub fn expect_broadcast_vote_requests(&mut self) -> &mut Expectation<T>
Create an Expectation for mocking the broadcast_vote_requests method
Sourcepub fn expect_handle_vote_request(&mut self) -> &mut Expectation<T>
pub fn expect_handle_vote_request(&mut self) -> &mut Expectation<T>
Create an Expectation for mocking the handle_vote_request method
Sourcepub fn expect_check_vote_request_is_legal(&mut self) -> &mut Expectation<T>
pub fn expect_check_vote_request_is_legal(&mut self) -> &mut Expectation<T>
Create an Expectation for mocking the check_vote_request_is_legal method
Trait Implementations§
Source§impl Clone for MockElectionCore<MockTypeConfig>
impl Clone for MockElectionCore<MockTypeConfig>
Source§impl<T> Debug for MockElectionCore<T>where
T: TypeConfig,
impl<T> Debug for MockElectionCore<T>where
T: TypeConfig,
Source§impl<T> Default for MockElectionCore<T>where
T: TypeConfig,
impl<T> Default for MockElectionCore<T>where
T: TypeConfig,
Source§impl<T> ElectionCore<T> for MockElectionCore<T>where
T: TypeConfig,
impl<T> ElectionCore<T> for MockElectionCore<T>where
T: TypeConfig,
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.
A vote can be granted only if all the following conditions are met:
- The requests term is greater than the current_term.
- The candidates log is sufficiently up-to-date.
- The current node has not voted in the current term or has already voted for the candidate.
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.
If there is a state update, we delegate the update to the parent RoleState instead of updating it within this function.
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
Validates vote request against Raft rules:
- Requester’s term must be ≥ current term
- Requester’s log must be at least as recent as local log
- Node hasn’t voted for another candidate in current term
Auto Trait Implementations§
impl<T> Freeze for MockElectionCore<T>
impl<T> RefUnwindSafe for MockElectionCore<T>where
T: RefUnwindSafe,
impl<T> Send for MockElectionCore<T>
impl<T> Sync for MockElectionCore<T>
impl<T> Unpin for MockElectionCore<T>where
T: Unpin,
impl<T> UnwindSafe for MockElectionCore<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
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>
T in a tonic::Request