Repository: tikv/raft-rs (Rust)

Issue:
Getters of public API are not conformant to RFC 344
**Is your feature request related to a problem? Please describe.**
In [RFC 344](https://github.com/rust-lang/rfcs/blob/master/text/0344-conventions-galore.md#gettersetter-apis) the idiomatic naming for getters and setters in rust is described. This library contains many methods in its public API that are not conformant to this RFC:

```
$ grep -RPn "pub fn.*get_" src
src/raft.rs:326:    pub fn get_store(&self) -> &T {
src/raft.rs:338:    pub fn get_snap(&self) -> Option<&Snapshot> {
src/raft.rs:384:    pub fn get_election_timeout(&self) -> usize {
src/raft.rs:389:    pub fn get_heartbeat_timeout(&self) -> usize {
src/raft.rs:394:    pub fn get_heartbeat_elapsed(&self) -> usize {
src/raft.rs:399:    pub fn get_randomized_election_timeout(&self) -> usize {
src/util.rs:86:    pub fn get_voters(&self) -> &[u64] {
src/progress/progress_set.rs:308:    pub fn get_mut(&mut self, id: u64) -> Option<&mut Progress> {
src/raw_node.rs:399:    pub fn get_snap(&self) -> Option<&Snapshot> {
src/raw_node.rs:483:    pub fn get_store(&self) -> &T {
src/prost/wrapper_eraftpb.rs:16:    pub fn get_entry_type(&self) -> EntryType {
src/prost/wrapper_eraftpb.rs:28:    pub fn get_term(&self) -> u64 {
src/prost/wrapper_eraftpb.rs:40:    pub fn get_index(&self) -> u64 {
src/prost/wrapper_eraftpb.rs:52:    pub fn get_data(&self) -> &[u8] {
src/prost/wrapper_eraftpb.rs:72:    pub fn get_context(&self) -> &[u8] {
src/prost/wrapper_eraftpb.rs:92:    pub fn get_sync_log(&self) -> bool {
src/prost/wrapper_eraftpb.rs:179:    pub fn get_conf_state(&self) -> &ConfState {
src/prost/wrapper_eraftpb.rs:209:    pub fn get_pending_membership_change(&self) -> &ConfState {
src/prost/wrapper_eraftpb.rs:237:    pub fn get_pending_membership_change_index(&self) -> u64 {
src/prost/wrapper_eraftpb.rs:249:    pub fn get_index(&self) -> u64 {
src/prost/wrapper_eraftpb.rs:261:    pub fn get_term(&self) -> u64 {
src/prost/wrapper_eraftpb.rs:344:    pub fn get_data(&self) -> &[u8] {
src/prost/wrapper_eraftpb.rs:368:    pub fn get_metadata(&self) -> &SnapshotMetadata {
src/prost/wrapper_eraftpb.rs:467:    pub fn get_msg_type(&self) -> MessageType {
src/prost/wrapper_eraftpb.rs:479:    pub fn get_to(&self) -> u64 {
src/prost/wrapper_eraftpb.rs:491:    pub fn get_from(&self) -> u64 {
src/prost/wrapper_eraftpb.rs:503:    pub fn get_term(&self) -> u64 {
src/prost/wrapper_eraftpb.rs:515:    pub fn get_log_term(&self) -> u64 {
src/prost/wrapper_eraftpb.rs:527:    pub fn get_index(&self) -> u64 {
src/prost/wrapper_eraftpb.rs:539:    pub fn get_entries(&self) -> &::std::vec::Vec<Entry> {
src/prost/wrapper_eraftpb.rs:559:    pub fn get_commit(&self) -> u64 {
src/prost/wrapper_eraftpb.rs:575:    pub fn get_snapshot(&self) -> &Snapshot {
src/prost/wrapper_eraftpb.rs:601:    pub fn get_reject(&self) -> bool {
src/prost/wrapper_eraftpb.rs:613:    pub fn get_reject_hint(&self) -> u64 {
src/prost/wrapper_eraftpb.rs:625:    pub fn get_context(&self) -> &[u8] {
src/prost/wrapper_eraftpb.rs:716:    pub fn get_term(&self) -> u64 {
src/prost/wrapper_eraftpb.rs:728:    pub fn get_vote(&self) -> u64 {
src/prost/wrapper_eraftpb.rs:740:    pub fn get_commit(&self) -> u64 {
src/prost/wrapper_eraftpb.rs:823:    pub fn get_nodes(&self) -> &::std::vec::Vec<u64> {
src/prost/wrapper_eraftpb.rs:843:    pub fn get_learners(&self) -> &::std::vec::Vec<u64> {
src/prost/wrapper_eraftpb.rs:934:    pub fn get_id(&self) -> u64 {
src/prost/wrapper_eraftpb.rs:946:    pub fn get_change_type(&self) -> ConfChangeType {
src/prost/wrapper_eraftpb.rs:958:    pub fn get_node_id(&self) -> u64 {
src/prost/wrapper_eraftpb.rs:970:    pub fn get_context(&self) -> &[u8] {
src/prost/wrapper_eraftpb.rs:994:    pub fn get_configuration(&self) -> &ConfState {
src/prost/wrapper_eraftpb.rs:1020:    pub fn get_start_index(&self) -> u64 {
src/raft_log.rs:111:    pub fn get_store(&self) -> &T {
src/raft_log.rs:279:    pub fn get_applied(&self) -> u64 {
src/raft_log.rs:294:    pub fn get_unstable(&self) -> &Unstable {
```

**Describe the solution you'd like**
Before releasing a 1.0 version of this library the methods that are not idiomatic getters can be refactored to match RFC 344.

**Describe alternatives you've considered**
An alternative is to not refactor the public API.

**Additional context**
This is not a technical issue, it's just the naming convention. I would consider it of low importance.



Discussion:
Thanks for your report~ 
PTAL @Hoverbear @hicqu 
Please ignore this part:

```
src/prost/wrapper_eraftpb.rs:16:    pub fn get_entry_type(&self) -> EntryType {
src/prost/wrapper_eraftpb.rs:28:    pub fn get_term(&self) -> u64 {
src/prost/wrapper_eraftpb.rs:40:    pub fn get_index(&self) -> u64 {
src/prost/wrapper_eraftpb.rs:52:    pub fn get_data(&self) -> &[u8] {
src/prost/wrapper_eraftpb.rs:72:    pub fn get_context(&self) -> &[u8] {
src/prost/wrapper_eraftpb.rs:92:    pub fn get_sync_log(&self) -> bool {
src/prost/wrapper_eraftpb.rs:179:    pub fn get_conf_state(&self) -> &ConfState {
src/prost/wrapper_eraftpb.rs:209:    pub fn get_pending_membership_change(&self) -> &ConfState {
src/prost/wrapper_eraftpb.rs:237:    pub fn get_pending_membership_change_index(&self) -> u64 {
src/prost/wrapper_eraftpb.rs:249:    pub fn get_index(&self) -> u64 {
src/prost/wrapper_eraftpb.rs:261:    pub fn get_term(&self) -> u64 {
src/prost/wrapper_eraftpb.rs:344:    pub fn get_data(&self) -> &[u8] {
src/prost/wrapper_eraftpb.rs:368:    pub fn get_metadata(&self) -> &SnapshotMetadata {
src/prost/wrapper_eraftpb.rs:467:    pub fn get_msg_type(&self) -> MessageType {
src/prost/wrapper_eraftpb.rs:479:    pub fn get_to(&self) -> u64 {
src/prost/wrapper_eraftpb.rs:491:    pub fn get_from(&self) -> u64 {
src/prost/wrapper_eraftpb.rs:503:    pub fn get_term(&self) -> u64 {
src/prost/wrapper_eraftpb.rs:515:    pub fn get_log_term(&self) -> u64 {
src/prost/wrapper_eraftpb.rs:527:    pub fn get_index(&self) -> u64 {
src/prost/wrapper_eraftpb.rs:539:    pub fn get_entries(&self) -> &::std::vec::Vec<Entry> {
src/prost/wrapper_eraftpb.rs:559:    pub fn get_commit(&self) -> u64 {
src/prost/wrapper_eraftpb.rs:575:    pub fn get_snapshot(&self) -> &Snapshot {
src/prost/wrapper_eraftpb.rs:601:    pub fn get_reject(&self) -> bool {
src/prost/wrapper_eraftpb.rs:613:    pub fn get_reject_hint(&self) -> u64 {
src/prost/wrapper_eraftpb.rs:625:    pub fn get_context(&self) -> &[u8] {
src/prost/wrapper_eraftpb.rs:716:    pub fn get_term(&self) -> u64 {
src/prost/wrapper_eraftpb.rs:728:    pub fn get_vote(&self) -> u64 {
src/prost/wrapper_eraftpb.rs:740:    pub fn get_commit(&self) -> u64 {
src/prost/wrapper_eraftpb.rs:823:    pub fn get_nodes(&self) -> &::std::vec::Vec<u64> {
src/prost/wrapper_eraftpb.rs:843:    pub fn get_learners(&self) -> &::std::vec::Vec<u64> {
src/prost/wrapper_eraftpb.rs:934:    pub fn get_id(&self) -> u64 {
src/prost/wrapper_eraftpb.rs:946:    pub fn get_change_type(&self) -> ConfChangeType {
src/prost/wrapper_eraftpb.rs:958:    pub fn get_node_id(&self) -> u64 {
src/prost/wrapper_eraftpb.rs:970:    pub fn get_context(&self) -> &[u8] {
src/prost/wrapper_eraftpb.rs:994:    pub fn get_configuration(&self) -> &ConfState {
src/prost/wrapper_eraftpb.rs:1020:    pub fn get_start_index(&self) -> u64 {
```

They'll be eliminated soon according to our discussion in tikv/protobuf-build#8
Thanks @fin-ger for raising this! :) I'm marking it as a recognized bug and we'll make sure to fix it!
FYI most of them are not eliminated:

```
~/git-repos/raft-rs λ> grep -RPn "pub fn.*get_" src
src/raft.rs:345:    pub fn get_store(&self) -> &T {
src/raft.rs:357:    pub fn get_snap(&self) -> Option<&Snapshot> {
src/raft.rs:403:    pub fn get_election_timeout(&self) -> usize {
src/raft.rs:408:    pub fn get_heartbeat_timeout(&self) -> usize {
src/raft.rs:413:    pub fn get_heartbeat_elapsed(&self) -> usize {
src/raft.rs:418:    pub fn get_randomized_election_timeout(&self) -> usize {
src/progress/progress_set.rs:327:    pub fn get_mut(&mut self, id: u64) -> Option<&mut Progress> {
src/raft_log.rs:141:    pub fn get_store(&self) -> &T {
src/raft_log.rs:310:    pub fn get_applied(&self) -> u64 {
src/raft_log.rs:325:    pub fn get_unstable(&self) -> &Unstable {
src/raw_node.rs:418:    pub fn get_snap(&self) -> Option<&Snapshot> {
src/raw_node.rs:502:    pub fn get_store(&self) -> &T {
```
Hi @Hoverbear, I saw that some of the methods are still not conformant with RFC 344. Is someone working on it? If not, I would love to work on it.
@psinghal20 Please! :)



Patch:
diff --git a/src/raft.rs b/src/raft.rs
index 90dbda930..61d58b1ab 100644
--- a/src/raft.rs
+++ b/src/raft.rs
@@ -340,7 +340,7 @@ impl<T: Storage> Raft<T> {
 
     /// Grabs an immutable reference to the store.
     #[inline]
-    pub fn get_store(&self) -> &T {
+    pub fn store(&self) -> &T {
         &self.raft_log.store
     }
 
@@ -352,7 +352,7 @@ impl<T: Storage> Raft<T> {
 
     /// Grabs a reference to the snapshot
     #[inline]
-    pub fn get_snap(&self) -> Option<&Snapshot> {
+    pub fn snap(&self) -> Option<&Snapshot> {
         self.raft_log.unstable.snapshot.as_ref()
     }
 
@@ -398,22 +398,22 @@ impl<T: Storage> Raft<T> {
     }
 
     /// Fetch the length of the election timeout.
-    pub fn get_election_timeout(&self) -> usize {
+    pub fn election_timeout(&self) -> usize {
         self.election_timeout
     }
 
     /// Fetch the length of the heartbeat timeout
-    pub fn get_heartbeat_timeout(&self) -> usize {
+    pub fn heartbeat_timeout(&self) -> usize {
         self.heartbeat_timeout
     }
 
     /// Fetch the number of ticks elapsed since last heartbeat.
-    pub fn get_heartbeat_elapsed(&self) -> usize {
+    pub fn heartbeat_elapsed(&self) -> usize {
         self.heartbeat_elapsed
     }
 
     /// Return the length of the current randomized election timeout.
-    pub fn get_randomized_election_timeout(&self) -> usize {
+    pub fn randomized_election_timeout(&self) -> usize {
         self.randomized_election_timeout
     }
 
@@ -2035,7 +2035,7 @@ impl<T: Storage> Raft<T> {
                 "drop request snapshot because of no leader";
                 "term" => self.term,
             );
-        } else if self.get_snap().is_some() {
+        } else if self.snap().is_some() {
             info!(
                 self.logger,
                 "there is a pending snapshot; dropping request snapshot";
diff --git a/src/raft_log.rs b/src/raft_log.rs
index 220b218f4..3dad8c8ae 100644
--- a/src/raft_log.rs
+++ b/src/raft_log.rs
@@ -105,7 +105,7 @@ impl<T: Storage> RaftLog<T> {
 
     /// Grab a read-only reference to the underlying storage.
     #[inline]
-    pub fn get_store(&self) -> &T {
+    pub fn store(&self) -> &T {
         &self.store
     }
 
@@ -279,7 +279,7 @@ impl<T: Storage> RaftLog<T> {
     }
 
     /// Returns the last applied index.
-    pub fn get_applied(&self) -> u64 {
+    pub fn applied(&self) -> u64 {
         self.applied
     }
 
@@ -294,7 +294,7 @@ impl<T: Storage> RaftLog<T> {
     }
 
     /// Returns a reference to the unstable log.
-    pub fn get_unstable(&self) -> &Unstable {
+    pub fn unstable(&self) -> &Unstable {
         &self.unstable
     }
 
diff --git a/src/raw_node.rs b/src/raw_node.rs
index 6b94702ac..172ec020a 100644
--- a/src/raw_node.rs
+++ b/src/raw_node.rs
@@ -387,7 +387,7 @@ impl<T: Storage> RawNode<T> {
         if !raft.read_states.is_empty() {
             return true;
         }
-        if self.get_snap().map_or(false, |s| !is_empty_snap(s)) {
+        if self.snap().map_or(false, |s| !is_empty_snap(s)) {
             return true;
         }
         let has_unapplied_entries = match applied_idx {
@@ -416,8 +416,8 @@ impl<T: Storage> RawNode<T> {
 
     /// Grabs the snapshot from the raft if available.
     #[inline]
-    pub fn get_snap(&self) -> Option<&Snapshot> {
-        self.raft.get_snap()
+    pub fn snap(&self) -> Option<&Snapshot> {
+        self.raft.snap()
     }
 
     /// Advance notifies the RawNode that the application has applied and saved progress in the
@@ -513,8 +513,8 @@ impl<T: Storage> RawNode<T> {
 
     /// Returns the store as an immutable reference.
     #[inline]
-    pub fn get_store(&self) -> &T {
-        self.raft.get_store()
+    pub fn store(&self) -> &T {
+        self.raft.store()
     }
 
     /// Returns the store as a mutable reference.
diff --git a/src/status.rs b/src/status.rs
index 64091c517..263d8f0bb 100644
--- a/src/status.rs
+++ b/src/status.rs
@@ -87,7 +87,7 @@ impl<'a> StatusRef<'a> {
         };
         s.hs = raft.hard_state();
         s.ss = raft.soft_state();
-        s.applied = raft.raft_log.get_applied();
+        s.applied = raft.raft_log.applied();
         if s.ss.raft_state == StateRole::Leader {
             s.progress = Some(raft.prs());
         }


Test patch:
diff --git a/harness/tests/integration_cases/test_membership_changes.rs b/harness/tests/integration_cases/test_membership_changes.rs
index 1e0231e53..7457a4d0b 100644
--- a/harness/tests/integration_cases/test_membership_changes.rs
+++ b/harness/tests/integration_cases/test_membership_changes.rs
@@ -356,9 +356,7 @@ mod remove_leader {
         info!(l, "Prompting a new election.");
         {
             let new_leader = scenario.peers.get_mut(&2).unwrap();
-            for _ in
-                new_leader.election_elapsed..=(new_leader.get_randomized_election_timeout() + 1)
-            {
+            for _ in new_leader.election_elapsed..=(new_leader.randomized_election_timeout() + 1) {
                 new_leader.tick();
             }
         }
@@ -376,7 +374,7 @@ mod remove_leader {
         info!(l, "Verifying that old leader cannot disrupt the cluster.");
         {
             let old_leader = scenario.peers.get_mut(&1).unwrap();
-            for _ in old_leader.get_heartbeat_elapsed()..=(old_leader.get_heartbeat_timeout() + 1) {
+            for _ in old_leader.heartbeat_elapsed()..=(old_leader.heartbeat_timeout() + 1) {
                 old_leader.tick();
             }
         }
@@ -433,9 +431,7 @@ mod remove_leader {
         info!(l, "Prompting a new election.");
         {
             let new_leader = scenario.peers.get_mut(&2).unwrap();
-            for _ in
-                new_leader.election_elapsed..=(new_leader.get_randomized_election_timeout() + 1)
-            {
+            for _ in new_leader.election_elapsed..=(new_leader.randomized_election_timeout() + 1) {
                 new_leader.tick();
             }
         }
@@ -451,7 +447,7 @@ mod remove_leader {
         info!(l, "Verifying that old leader cannot disrupt the cluster.");
         {
             let old_leader = scenario.peers.get_mut(&1).unwrap();
-            for _ in old_leader.get_heartbeat_elapsed()..=(old_leader.get_heartbeat_timeout() + 1) {
+            for _ in old_leader.heartbeat_elapsed()..=(old_leader.heartbeat_timeout() + 1) {
                 old_leader.tick();
             }
         }
@@ -576,7 +572,7 @@ mod three_peers_replace_voter {
             let peer = scenario.peers.get_mut(&1).unwrap();
             peer.become_candidate();
             peer.become_leader();
-            for _ in peer.get_heartbeat_elapsed()..=(peer.get_heartbeat_timeout() + 1) {
+            for _ in peer.heartbeat_elapsed()..=(peer.heartbeat_timeout() + 1) {
                 peer.tick();
             }
         }
@@ -877,8 +873,8 @@ mod three_peers_replace_voter {
             l,
             "Spinning for awhile to ensure nothing spectacular happens"
         );
-        for _ in scenario.peers[&leader].get_heartbeat_elapsed()
-            ..=scenario.peers[&leader].get_heartbeat_timeout()
+        for _ in scenario.peers[&leader].heartbeat_elapsed()
+            ..=scenario.peers[&leader].heartbeat_timeout()
         {
             scenario.peers.iter_mut().for_each(|(_, peer)| {
                 peer.tick();
@@ -893,8 +889,8 @@ mod three_peers_replace_voter {
         info!(l, "Recovering old qourum.");
         scenario.recover();
 
-        for _ in scenario.peers[&leader].get_heartbeat_elapsed()
-            ..=scenario.peers[&leader].get_heartbeat_timeout()
+        for _ in scenario.peers[&leader].heartbeat_elapsed()
+            ..=scenario.peers[&leader].heartbeat_timeout()
         {
             scenario.peers.iter_mut().for_each(|(_, peer)| {
                 peer.tick();
@@ -965,8 +961,8 @@ mod three_peers_replace_voter {
             l,
             "Spinning for awhile to ensure nothing spectacular happens"
         );
-        for _ in scenario.peers[&leader].get_heartbeat_elapsed()
-            ..=scenario.peers[&leader].get_heartbeat_timeout()
+        for _ in scenario.peers[&leader].heartbeat_elapsed()
+            ..=scenario.peers[&leader].heartbeat_timeout()
         {
             scenario.peers.iter_mut().for_each(|(_, peer)| {
                 peer.tick();
@@ -981,8 +977,8 @@ mod three_peers_replace_voter {
         info!(l, "Recovering new qourum.");
         scenario.recover();
 
-        for _ in scenario.peers[&leader].get_heartbeat_elapsed()
-            ..=scenario.peers[&leader].get_heartbeat_timeout()
+        for _ in scenario.peers[&leader].heartbeat_elapsed()
+            ..=scenario.peers[&leader].heartbeat_timeout()
         {
             scenario.peers.iter_mut().for_each(|(_, peer)| {
                 peer.tick();
@@ -1118,7 +1114,7 @@ mod three_peers_to_five_with_learner {
         info!(l, "Cluster leaving the joint.");
         {
             let leader = scenario.peers.get_mut(&1).unwrap();
-            let ticks = leader.get_heartbeat_timeout();
+            let ticks = leader.heartbeat_timeout();
             for _ in 0..=ticks {
                 leader.tick();
             }
diff --git a/harness/tests/integration_cases/test_raft.rs b/harness/tests/integration_cases/test_raft.rs
index b4ea589ee..6bf7f5953 100644
--- a/harness/tests/integration_cases/test_raft.rs
+++ b/harness/tests/integration_cases/test_raft.rs
@@ -1701,7 +1701,7 @@ fn test_candidate_reset_term(message_type: MessageType, l: &Logger) {
         .get_mut(&3)
         .unwrap()
         .reset_randomized_election_timeout();
-    let timeout = nt.peers[&3].get_randomized_election_timeout();
+    let timeout = nt.peers[&3].randomized_election_timeout();
     for _ in 0..timeout {
         nt.peers.get_mut(&3).unwrap().tick();
     }
@@ -1734,7 +1734,7 @@ fn test_leader_stepdown_when_quorum_active() {
     sm.become_candidate();
     sm.become_leader();
 
-    for _ in 0..=sm.get_election_timeout() {
+    for _ in 0..=sm.election_timeout() {
         let mut m = new_message(2, 0, MessageType::MsgHeartbeatResponse, 0);
         m.term = sm.term;
         sm.step(m).expect("");
@@ -1754,7 +1754,7 @@ fn test_leader_stepdown_when_quorum_lost() {
     sm.become_candidate();
     sm.become_leader();
 
-    for _ in 0..=sm.get_election_timeout() {
+    for _ in 0..=sm.election_timeout() {
         sm.tick();
     }
 
@@ -1774,7 +1774,7 @@ fn test_leader_superseding_with_check_quorum() {
 
     let mut nt = Network::new(vec![Some(a), Some(b), Some(c)], &l);
 
-    let b_election_timeout = nt.peers[&2].get_election_timeout();
+    let b_election_timeout = nt.peers[&2].election_timeout();
 
     // prevent campaigning from b
     nt.peers
@@ -1818,8 +1818,8 @@ fn test_leader_election_with_check_quorum() {
     // we can not let system choosing the value of randomizedElectionTimeout
     // otherwise it will introduce some uncertainty into this test case
     // we need to ensure randomizedElectionTimeout > electionTimeout here
-    let a_election_timeout = nt.peers[&1].get_election_timeout();
-    let b_election_timeout = nt.peers[&2].get_election_timeout();
+    let a_election_timeout = nt.peers[&1].election_timeout();
+    let b_election_timeout = nt.peers[&2].election_timeout();
     nt.peers
         .get_mut(&1)
         .unwrap()
@@ -1838,8 +1838,8 @@ fn test_leader_election_with_check_quorum() {
 
     // need to reset randomizedElectionTimeout larger than electionTimeout again,
     // because the value might be reset to electionTimeout since the last state changes
-    let a_election_timeout = nt.peers[&1].get_election_timeout();
-    let b_election_timeout = nt.peers[&2].get_election_timeout();
+    let a_election_timeout = nt.peers[&1].election_timeout();
+    let b_election_timeout = nt.peers[&2].election_timeout();
     nt.peers
         .get_mut(&1)
         .unwrap()
@@ -1880,7 +1880,7 @@ fn test_free_stuck_candidate_with_check_quorum() {
     // we can not let system choosing the value of randomizedElectionTimeout
     // otherwise it will introduce some uncertainty into this test case
     // we need to ensure randomizedElectionTimeout > electionTimeout here
-    let b_election_timeout = nt.peers[&2].get_election_timeout();
+    let b_election_timeout = nt.peers[&2].election_timeout();
     nt.peers
         .get_mut(&2)
         .unwrap()
@@ -1932,7 +1932,7 @@ fn test_non_promotable_voter_which_check_quorum() {
     // we can not let system choosing the value of randomizedElectionTimeout
     // otherwise it will introduce some uncertainty into this test case
     // we need to ensure randomizedElectionTimeout > electionTimeout here
-    let b_election_timeout = nt.peers[&2].get_election_timeout();
+    let b_election_timeout = nt.peers[&2].election_timeout();
     nt.peers
         .get_mut(&2)
         .unwrap()
@@ -1986,12 +1986,12 @@ fn test_disruptive_follower() {
     // this is to expedite campaign trigger when given larger
     // election timeouts (e.g. multi-datacenter deploy)
     // Or leader messages are being delayed while ticks elapse
-    let timeout = nt.peers[&3].get_election_timeout();
+    let timeout = nt.peers[&3].election_timeout();
     nt.peers
         .get_mut(&3)
         .unwrap()
         .set_randomized_election_timeout(timeout + 2);
-    let timeout = nt.peers[&3].get_randomized_election_timeout();
+    let timeout = nt.peers[&3].randomized_election_timeout();
     for _ in 0..timeout - 1 {
         nt.peers.get_mut(&3).unwrap().tick();
     }
@@ -2113,7 +2113,7 @@ fn test_read_only_option_safe() {
     // we can not let system choose the value of randomizedElectionTimeout
     // otherwise it will introduce some uncertainty into this test case
     // we need to ensure randomizedElectionTimeout > electionTimeout here
-    let b_election_timeout = nt.peers[&2].get_election_timeout();
+    let b_election_timeout = nt.peers[&2].election_timeout();
     nt.peers
         .get_mut(&2)
         .unwrap()
@@ -2203,7 +2203,7 @@ fn test_read_only_with_learner() {
     // we can not let system choose the value of randomizedElectionTimeout
     // otherwise it will introduce some uncertainty into this test case
     // we need to ensure randomizedElectionTimeout > electionTimeout here
-    let b_election_timeout = nt.peers[&2].get_election_timeout();
+    let b_election_timeout = nt.peers[&2].election_timeout();
     nt.peers
         .get_mut(&2)
         .unwrap()
@@ -2283,7 +2283,7 @@ fn test_read_only_option_lease() {
     // we can not let system choose the value of randomizedElectionTimeout
     // otherwise it will introduce some uncertainty into this test case
     // we need to ensure randomizedElectionTimeout > electionTimeout here
-    let b_election_timeout = nt.peers[&2].get_election_timeout();
+    let b_election_timeout = nt.peers[&2].election_timeout();
     nt.peers
         .get_mut(&2)
         .unwrap()
@@ -2702,7 +2702,7 @@ fn test_send_append_for_progress_probe() {
         }
 
         // do a heartbeat
-        for _ in 0..r.get_heartbeat_timeout() {
+        for _ in 0..r.heartbeat_timeout() {
             r.step(new_message(1, 1, MessageType::MsgBeat, 0))
                 .expect("");
         }
@@ -3026,7 +3026,7 @@ fn test_add_node_check_quorum() -> Result<()> {
     r.become_candidate();
     r.become_leader();
 
-    for _ in 0..r.get_election_timeout() - 1 {
+    for _ in 0..r.election_timeout() - 1 {
         r.tick();
     }
 
@@ -3040,7 +3040,7 @@ fn test_add_node_check_quorum() -> Result<()> {
 
     // After another electionTimeout ticks without hearing from node 2,
     // node 1 should step down.
-    for _ in 0..r.get_election_timeout() {
+    for _ in 0..r.election_timeout() {
         r.tick();
     }
 
@@ -3242,11 +3242,11 @@ fn test_leader_transfer_with_check_quorum() {
     for i in 1..4 {
         let r = &mut nt.peers.get_mut(&i).unwrap();
         r.check_quorum = true;
-        let election_timeout = r.get_election_timeout();
+        let election_timeout = r.election_timeout();
         r.set_randomized_election_timeout(election_timeout + i as usize);
     }
 
-    let b_election_timeout = nt.peers[&2].get_election_timeout();
+    let b_election_timeout = nt.peers[&2].election_timeout();
     nt.peers
         .get_mut(&2)
         .unwrap()
@@ -3375,8 +3375,8 @@ fn test_leader_transfer_timeout() {
     // Transfer leadership to isolated node, wait for timeout.
     nt.send(vec![new_message(3, 1, MessageType::MsgTransferLeader, 0)]);
     assert_eq!(nt.peers[&1].lead_transferee.unwrap(), 3);
-    let heartbeat_timeout = nt.peers[&1].get_heartbeat_timeout();
-    let election_timeout = nt.peers[&1].get_election_timeout();
+    let heartbeat_timeout = nt.peers[&1].heartbeat_timeout();
+    let election_timeout = nt.peers[&1].election_timeout();
     for _ in 0..heartbeat_timeout {
         nt.peers.get_mut(&1).unwrap().tick();
     }
@@ -3505,7 +3505,7 @@ fn test_leader_transfer_second_transfer_to_same_node() {
     nt.send(vec![new_message(3, 1, MessageType::MsgTransferLeader, 0)]);
     assert_eq!(nt.peers[&1].lead_transferee.unwrap(), 3);
 
-    let heartbeat_timeout = nt.peers[&1].get_heartbeat_timeout();
+    let heartbeat_timeout = nt.peers[&1].heartbeat_timeout();
     for _ in 0..heartbeat_timeout {
         nt.peers.get_mut(&1).unwrap().tick();
     }
@@ -3513,7 +3513,7 @@ fn test_leader_transfer_second_transfer_to_same_node() {
     // Second transfer leadership request to the same node.
     nt.send(vec![new_message(3, 1, MessageType::MsgTransferLeader, 0)]);
 
-    let election_timeout = nt.peers[&1].get_election_timeout();
+    let election_timeout = nt.peers[&1].election_timeout();
     for _ in 0..election_timeout - heartbeat_timeout {
         nt.peers.get_mut(&1).unwrap().tick();
     }
@@ -3645,7 +3645,7 @@ fn test_learner_election_timeout() {
     let mut n2 = new_test_learner_raft(2, vec![1], vec![2], 10, 1, new_storage(), &l);
     n2.become_follower(1, INVALID_ID);
 
-    let timeout = n2.get_election_timeout();
+    let timeout = n2.election_timeout();
     n2.set_randomized_election_timeout(timeout);
 
     // n2 is a learner. Learner should not start election even when time out.
@@ -3670,7 +3670,7 @@ fn test_learner_promotion() -> Result<()> {
     assert_eq!(network.peers[&1].state, StateRole::Follower);
 
     // n1 should become leader.
-    let timeout = network.peers[&1].get_election_timeout();
+    let timeout = network.peers[&1].election_timeout();
     network
         .peers
         .get_mut(&1)
@@ -3691,7 +3691,7 @@ fn test_learner_promotion() -> Result<()> {
     assert_eq!(network.peers[&2].state, StateRole::Follower);
     assert!(network.peers[&2].promotable());
 
-    let timeout = network.peers[&2].get_election_timeout();
+    let timeout = network.peers[&2].election_timeout();
     network
         .peers
         .get_mut(&2)
@@ -3729,7 +3729,7 @@ fn test_learner_log_replication() {
         .unwrap()
         .become_follower(1, INVALID_ID);
 
-    let timeout = network.peers[&1].get_election_timeout();
+    let timeout = network.peers[&1].election_timeout();
     network
         .peers
         .get_mut(&1)
@@ -3848,7 +3848,7 @@ fn test_learner_receive_snapshot() {
 
     let mut network = Network::new(vec![Some(n1), Some(n2)], &l);
 
-    let timeout = network.peers[&1].get_election_timeout();
+    let timeout = network.peers[&1].election_timeout();
     network
         .peers
         .get_mut(&1)
@@ -4068,7 +4068,7 @@ fn test_election_tick_range() {
     let mut raft = new_test_raft_with_config(&cfg, s, &l).raft.unwrap();
     for _ in 0..1000 {
         raft.reset_randomized_election_timeout();
-        let randomized_timeout = raft.get_randomized_election_timeout();
+        let randomized_timeout = raft.randomized_election_timeout();
         assert!(
             cfg.election_tick <= randomized_timeout && randomized_timeout < 2 * cfg.election_tick
         );
@@ -4092,7 +4092,7 @@ fn test_election_tick_range() {
         .unwrap();
     for _ in 0..100 {
         raft.reset_randomized_election_timeout();
-        let randomized_timeout = raft.get_randomized_election_timeout();
+        let randomized_timeout = raft.randomized_election_timeout();
         assert_eq!(randomized_timeout, cfg.election_tick);
     }
 }
@@ -4204,7 +4204,7 @@ fn test_prevote_with_check_quorum() {
     network.cut(1, 3);
 
     // call for election. node 3 shouldn't ignore node 2's PreVote
-    let timeout = network.peers[&3].get_randomized_election_timeout();
+    let timeout = network.peers[&3].randomized_election_timeout();
     for _ in 0..timeout {
         network.peers.get_mut(&3).unwrap().tick();
     }
@@ -4274,7 +4274,7 @@ fn test_conf_change_check_before_campaign() {
         .get_mut(&2)
         .unwrap()
         .reset_randomized_election_timeout();
-    let timeout = nt.peers[&2].get_randomized_election_timeout();
+    let timeout = nt.peers[&2].randomized_election_timeout();
     for _ in 0..timeout {
         nt.peers.get_mut(&2).unwrap().tick();
     }
@@ -4306,7 +4306,7 @@ fn test_conf_change_check_before_campaign() {
         .get_mut(&1)
         .unwrap()
         .reset_randomized_election_timeout();
-    let timeout = nt.peers[&1].get_randomized_election_timeout();
+    let timeout = nt.peers[&1].randomized_election_timeout();
     for _ in 0..timeout {
         nt.peers.get_mut(&1).unwrap().tick();
     }
@@ -4443,7 +4443,7 @@ fn test_request_snapshot_unavailable() {
     );
 
     // Peer 2 is still in probe state due to SnapshotTemporarilyUnavailable.
-    nt.peers[&1].get_store().wl().trigger_snap_unavailable();
+    nt.peers[&1].store().wl().trigger_snap_unavailable();
     nt.peers
         .get_mut(&1)
         .unwrap()
@@ -4455,7 +4455,7 @@ fn test_request_snapshot_unavailable() {
     );
 
     // Next index is decreased.
-    nt.peers[&1].get_store().wl().trigger_snap_unavailable();
+    nt.peers[&1].store().wl().trigger_snap_unavailable();
     nt.peers
         .get_mut(&1)
         .unwrap()
@@ -4502,7 +4502,7 @@ fn test_request_snapshot_matched_change() {
     );
 
     // Heartbeat is responsed with a request snapshot message.
-    for _ in 0..nt.peers[&1].get_heartbeat_timeout() {
+    for _ in 0..nt.peers[&1].heartbeat_timeout() {
         nt.peers.get_mut(&1).unwrap().tick();
     }
     let msg_hb = nt
diff --git a/harness/tests/integration_cases/test_raft_paper.rs b/harness/tests/integration_cases/test_raft_paper.rs
index c5b5db9c1..e5ad39747 100644
--- a/harness/tests/integration_cases/test_raft_paper.rs
+++ b/harness/tests/integration_cases/test_raft_paper.rs
@@ -916,7 +916,7 @@ fn test_vote_request() {
         r.step(m).expect("");
         r.read_messages();
 
-        for _ in 1..r.get_election_timeout() * 2 {
+        for _ in 1..r.election_timeout() * 2 {
             r.tick_election();
         }
 
diff --git a/harness/tests/integration_cases/test_raw_node.rs b/harness/tests/integration_cases/test_raw_node.rs
index 53021453f..f6ee5daeb 100644
--- a/harness/tests/integration_cases/test_raw_node.rs
+++ b/harness/tests/integration_cases/test_raw_node.rs
@@ -448,7 +448,7 @@ fn test_skip_bcast_commit() {
     assert_eq!(nt.peers[&3].raft_log.committed, 2);
 
     // After bcast heartbeat, followers will be informed the actual commit index.
-    for _ in 0..nt.peers[&1].get_randomized_election_timeout() {
+    for _ in 0..nt.peers[&1].randomized_election_timeout() {
         nt.peers.get_mut(&1).unwrap().tick();
     }
     nt.send(vec![new_message(1, 1, MessageType::MsgHup, 0)]);