pub struct MockMembership<T>where
T: TypeConfig,{ /* private fields */ }Implementations§
Source§impl<T> MockMembership<T>where
T: TypeConfig,
impl<T> MockMembership<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> MockMembership<T>where
T: TypeConfig,
impl<T> MockMembership<T>where
T: TypeConfig,
Sourcepub fn expect_members(&mut self) -> &mut Expectation<T>
pub fn expect_members(&mut self) -> &mut Expectation<T>
Create an Expectation for mocking the members method
Sourcepub fn expect_replication_peers(&mut self) -> &mut Expectation<T>
pub fn expect_replication_peers(&mut self) -> &mut Expectation<T>
Create an Expectation for mocking the replication_peers method
Sourcepub fn expect_voters(&mut self) -> &mut Expectation<T>
pub fn expect_voters(&mut self) -> &mut Expectation<T>
Create an Expectation for mocking the voters method
Sourcepub fn expect_initial_cluster_size(&mut self) -> &mut Expectation<T>
pub fn expect_initial_cluster_size(&mut self) -> &mut Expectation<T>
Create an Expectation for mocking the initial_cluster_size method
Sourcepub fn expect_is_single_node_cluster(&mut self) -> &mut Expectation<T>
pub fn expect_is_single_node_cluster(&mut self) -> &mut Expectation<T>
Create an Expectation for mocking the is_single_node_cluster method
Sourcepub fn expect_nodes_with_status(&mut self) -> &mut Expectation<T>
pub fn expect_nodes_with_status(&mut self) -> &mut Expectation<T>
Create an Expectation for mocking the nodes_with_status method
Sourcepub fn expect_get_node_status(&mut self) -> &mut Expectation<T>
pub fn expect_get_node_status(&mut self) -> &mut Expectation<T>
Create an Expectation for mocking the get_node_status method
Sourcepub fn expect_check_cluster_is_ready(&mut self) -> &mut Expectation<T>
pub fn expect_check_cluster_is_ready(&mut self) -> &mut Expectation<T>
Create an Expectation for mocking the check_cluster_is_ready method
Sourcepub fn expect_get_peers_id_with_condition(&mut self) -> &mut Expectation<T>
pub fn expect_get_peers_id_with_condition(&mut self) -> &mut Expectation<T>
Create an Expectation for mocking the get_peers_id_with_condition method
Sourcepub fn expect_retrieve_cluster_membership_config(
&mut self,
) -> &mut Expectation<T>
pub fn expect_retrieve_cluster_membership_config( &mut self, ) -> &mut Expectation<T>
Create an Expectation for mocking the retrieve_cluster_membership_config method
Sourcepub fn expect_update_cluster_conf_from_leader(&mut self) -> &mut Expectation<T>
pub fn expect_update_cluster_conf_from_leader(&mut self) -> &mut Expectation<T>
Create an Expectation for mocking the update_cluster_conf_from_leader method
Sourcepub fn expect_get_cluster_conf_version(&mut self) -> &mut Expectation<T>
pub fn expect_get_cluster_conf_version(&mut self) -> &mut Expectation<T>
Create an Expectation for mocking the get_cluster_conf_version method
Sourcepub fn expect_update_conf_version(&mut self) -> &mut Expectation<T>
pub fn expect_update_conf_version(&mut self) -> &mut Expectation<T>
Create an Expectation for mocking the update_conf_version method
Sourcepub fn expect_incr_conf_version(&mut self) -> &mut Expectation<T>
pub fn expect_incr_conf_version(&mut self) -> &mut Expectation<T>
Create an Expectation for mocking the incr_conf_version method
Sourcepub fn expect_add_learner(&mut self) -> &mut Expectation<T>
pub fn expect_add_learner(&mut self) -> &mut Expectation<T>
Create an Expectation for mocking the add_learner method
Sourcepub fn expect_activate_node(&mut self) -> &mut Expectation<T>
pub fn expect_activate_node(&mut self) -> &mut Expectation<T>
Create an Expectation for mocking the activate_node method
Sourcepub fn expect_update_node_status(&mut self) -> &mut Expectation<T>
pub fn expect_update_node_status(&mut self) -> &mut Expectation<T>
Create an Expectation for mocking the update_node_status method
Sourcepub fn expect_contains_node(&mut self) -> &mut Expectation<T>
pub fn expect_contains_node(&mut self) -> &mut Expectation<T>
Create an Expectation for mocking the contains_node method
Sourcepub fn expect_retrieve_node_meta(&mut self) -> &mut Expectation<T>
pub fn expect_retrieve_node_meta(&mut self) -> &mut Expectation<T>
Create an Expectation for mocking the retrieve_node_meta method
Sourcepub fn expect_remove_node(&mut self) -> &mut Expectation<T>
pub fn expect_remove_node(&mut self) -> &mut Expectation<T>
Create an Expectation for mocking the remove_node method
Sourcepub fn expect_force_remove_node(&mut self) -> &mut Expectation<T>
pub fn expect_force_remove_node(&mut self) -> &mut Expectation<T>
Create an Expectation for mocking the force_remove_node method
Sourcepub fn expect_get_all_nodes(&mut self) -> &mut Expectation<T>
pub fn expect_get_all_nodes(&mut self) -> &mut Expectation<T>
Create an Expectation for mocking the get_all_nodes method
Sourcepub fn expect_pre_warm_connections(&mut self) -> &mut Expectation<T>
pub fn expect_pre_warm_connections(&mut self) -> &mut Expectation<T>
Create an Expectation for mocking the pre_warm_connections method
Sourcepub fn expect_get_peer_channel(&mut self) -> &mut Expectation<T>
pub fn expect_get_peer_channel(&mut self) -> &mut Expectation<T>
Create an Expectation for mocking the get_peer_channel method
Sourcepub fn expect_get_address(&mut self) -> &mut Expectation<T>
pub fn expect_get_address(&mut self) -> &mut Expectation<T>
Create an Expectation for mocking the get_address method
Sourcepub fn expect_apply_config_change(&mut self) -> &mut Expectation<T>
pub fn expect_apply_config_change(&mut self) -> &mut Expectation<T>
Create an Expectation for mocking the apply_config_change method
Sourcepub fn expect_notify_config_applied(&mut self) -> &mut Expectation<T>
pub fn expect_notify_config_applied(&mut self) -> &mut Expectation<T>
Create an Expectation for mocking the notify_config_applied method
Sourcepub fn expect_get_zombie_candidates(&mut self) -> &mut Expectation<T>
pub fn expect_get_zombie_candidates(&mut self) -> &mut Expectation<T>
Create an Expectation for mocking the get_zombie_candidates method
Sourcepub fn expect_can_rejoin(&mut self) -> &mut Expectation<T>
pub fn expect_can_rejoin(&mut self) -> &mut Expectation<T>
Create an Expectation for mocking the can_rejoin method
Trait Implementations§
Source§impl<T> Debug for MockMembership<T>where
T: TypeConfig,
impl<T> Debug for MockMembership<T>where
T: TypeConfig,
Source§impl<T> Default for MockMembership<T>where
T: TypeConfig,
impl<T> Default for MockMembership<T>where
T: TypeConfig,
Source§impl<T> Membership<T> for MockMembership<T>where
T: TypeConfig,
impl<T> Membership<T> for MockMembership<T>where
T: TypeConfig,
Source§fn members<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<NodeMeta>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn members<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<NodeMeta>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
All nodes (including itself)
Source§fn replication_peers<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<NodeMeta>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn replication_peers<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<NodeMeta>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
All non-self nodes (including Syncing and Active) Note: Joining node has not start its Raft event processing engine yet.
Source§fn voters<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<NodeMeta>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn voters<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<NodeMeta>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
All non-self nodes in Active state
Source§fn initial_cluster_size<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn initial_cluster_size<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get the initial cluster size from configuration
This value is determined at node startup from the initial_cluster configuration
and remains constant throughout the node’s lifetime. It represents the designed
cluster size, not the current runtime membership state.
Used for:
- Quorum calculations
- Cluster topology decisions
§Safety
This method is safe to use for cluster topology decisions as it’s based on immutable configuration rather than runtime state that could be affected by network partitions or bugs.
Source§fn is_single_node_cluster<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn is_single_node_cluster<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Check if this is a single-node cluster
Returns true if the initial cluster size is 1, indicating this node
was configured to run in standalone mode without any peers.
This is a convenience method equivalent to initial_cluster_size() == 1.
§Use Cases
- Skip Raft election in single-node mode (no peers to vote)
- Skip log replication in single-node mode (no peers to replicate to)
- Optimize performance by avoiding unnecessary network operations
§Safety
Safe for all cluster topology decisions as it’s based on immutable configuration.
Source§fn nodes_with_status<'life0, 'async_trait>(
&'life0 self,
status: NodeStatus,
) -> Pin<Box<dyn Future<Output = Vec<NodeMeta>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn nodes_with_status<'life0, 'async_trait>(
&'life0 self,
status: NodeStatus,
) -> Pin<Box<dyn Future<Output = Vec<NodeMeta>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
All pending active nodes in Active state
Source§fn retrieve_cluster_membership_config<'life0, 'async_trait>(
&'life0 self,
current_leader_id: Option<u32>,
) -> Pin<Box<dyn Future<Output = ClusterMembership> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn retrieve_cluster_membership_config<'life0, 'async_trait>(
&'life0 self,
current_leader_id: Option<u32>,
) -> Pin<Box<dyn Future<Output = ClusterMembership> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
retrieve latest cluster membership with current leader ID
§Parameters
current_leader_id: Optional current leader ID from runtime state
Source§fn update_cluster_conf_from_leader<'life0, 'life1, 'async_trait>(
&'life0 self,
my_id: u32,
my_current_term: u64,
current_conf_version: u64,
current_leader_id: Option<u32>,
cluster_conf_change_req: &'life1 ClusterConfChangeRequest,
) -> Pin<Box<dyn Future<Output = Result<ClusterConfUpdateResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn update_cluster_conf_from_leader<'life0, 'life1, 'async_trait>(
&'life0 self,
my_id: u32,
my_current_term: u64,
current_conf_version: u64,
current_leader_id: Option<u32>,
cluster_conf_change_req: &'life1 ClusterConfChangeRequest,
) -> Pin<Box<dyn Future<Output = Result<ClusterConfUpdateResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
invoked when receive requests from Leader
Source§fn add_learner<'life0, 'async_trait>(
&'life0 self,
node_id: u32,
address: String,
status: NodeStatus,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn add_learner<'life0, 'async_trait>(
&'life0 self,
node_id: u32,
address: String,
status: NodeStatus,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Add a new node as a learner
Source§fn activate_node<'life0, 'async_trait>(
&'life0 mut self,
new_node_id: u32,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn activate_node<'life0, 'async_trait>(
&'life0 mut self,
new_node_id: u32,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Activate node
Source§fn update_node_status<'life0, 'async_trait>(
&'life0 self,
node_id: u32,
status: NodeStatus,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn update_node_status<'life0, 'async_trait>(
&'life0 self,
node_id: u32,
status: NodeStatus,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Update status of a node
Source§fn contains_node<'life0, 'async_trait>(
&'life0 self,
node_id: u32,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn contains_node<'life0, 'async_trait>(
&'life0 self,
node_id: u32,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Check if the node already exists
Source§fn remove_node<'life0, 'async_trait>(
&'life0 self,
node_id: u32,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn remove_node<'life0, 'async_trait>(
&'life0 self,
node_id: u32,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Elegantly remove nodes
Source§fn force_remove_node<'life0, 'async_trait>(
&'life0 self,
node_id: u32,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn force_remove_node<'life0, 'async_trait>(
&'life0 self,
node_id: u32,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Forcefully remove faulty nodes
Source§fn get_all_nodes<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<NodeMeta>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_all_nodes<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<NodeMeta>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get all node status
Source§fn pre_warm_connections<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn pre_warm_connections<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Pre-warms connection cache for all replication peers
Source§fn apply_config_change<'life0, 'async_trait>(
&'life0 self,
change: MembershipChange,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn apply_config_change<'life0, 'async_trait>(
&'life0 self,
change: MembershipChange,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Apply committed configuration change
Source§fn can_rejoin<'life0, 'async_trait>(
&'life0 self,
node_id: u32,
role: i32,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn can_rejoin<'life0, 'async_trait>(
&'life0 self,
node_id: u32,
role: i32,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
If new node could rejoin the cluster again
fn get_node_status<'life0, 'async_trait>(
&'life0 self,
node_id: u32,
) -> Pin<Box<dyn Future<Output = Option<NodeStatus>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn check_cluster_is_ready<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_peers_id_with_condition<'life0, 'async_trait, F>( &'life0 self, condition: F, ) -> Pin<Box<dyn Future<Output = Vec<u32>> + Send + 'async_trait>>
fn get_cluster_conf_version<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = u64> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn update_conf_version<'life0, 'async_trait>(
&'life0 self,
version: u64,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn incr_conf_version<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn retrieve_node_meta<'life0, 'async_trait>(
&'life0 self,
node_id: u32,
) -> Pin<Box<dyn Future<Output = Option<NodeMeta>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_peer_channel<'life0, 'async_trait>(
&'life0 self,
node_id: u32,
conn_type: ConnectionType,
) -> Pin<Box<dyn Future<Output = Option<Channel>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_address<'life0, 'async_trait>(
&'life0 self,
node_id: u32,
) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn notify_config_applied<'life0, 'async_trait>(
&'life0 self,
index: u64,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_zombie_candidates<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<u32>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl<T> Freeze for MockMembership<T>
impl<T> RefUnwindSafe for MockMembership<T>where
T: RefUnwindSafe,
impl<T> Send for MockMembership<T>
impl<T> Sync for MockMembership<T>
impl<T> Unpin for MockMembership<T>where
T: Unpin,
impl<T> UnwindSafe for MockMembership<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> 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