Skip to content

Commit e056998

Browse files
committed
Change: remove unused trait RaftStorageDebug
`RaftStorageDebug` has only one method `get_state_machine()`, and state machine is entirely a user defined struct. Obtaining a state machine does not imply anything about the struct or behavior of it.
1 parent 964047b commit e056998

File tree

5 files changed

+6
-31
lines changed

5 files changed

+6
-31
lines changed

memstore/src/lib.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use openraft::EntryPayload;
2121
use openraft::LogId;
2222
use openraft::RaftLogId;
2323
use openraft::RaftStorage;
24-
use openraft::RaftStorageDebug;
2524
use openraft::SnapshotMeta;
2625
use openraft::StorageError;
2726
use openraft::StorageIOError;
@@ -136,6 +135,11 @@ impl MemStore {
136135
pub async fn new_async() -> Arc<Self> {
137136
Arc::new(Self::new())
138137
}
138+
139+
/// Get a handle to the state machine for testing purposes.
140+
pub async fn get_state_machine(&self) -> MemStoreStateMachine {
141+
self.sm.write().await.clone()
142+
}
139143
}
140144

141145
impl Default for MemStore {
@@ -144,14 +148,6 @@ impl Default for MemStore {
144148
}
145149
}
146150

147-
#[async_trait]
148-
impl RaftStorageDebug<MemStoreStateMachine> for Arc<MemStore> {
149-
/// Get a handle to the state machine for testing purposes.
150-
async fn get_state_machine(&mut self) -> MemStoreStateMachine {
151-
self.sm.write().await.clone()
152-
}
153-
}
154-
155151
#[async_trait]
156152
impl RaftLogReader<Config> for Arc<MemStore> {
157153
async fn try_get_log_entries<RB: RangeBounds<u64> + Clone + Debug + Send + Sync>(

openraft/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ pub use crate::storage::LogState;
119119
pub use crate::storage::RaftLogReader;
120120
pub use crate::storage::RaftSnapshotBuilder;
121121
pub use crate::storage::RaftStorage;
122-
pub use crate::storage::RaftStorageDebug;
123122
pub use crate::storage::Snapshot;
124123
pub use crate::storage::SnapshotMeta;
125124
pub use crate::storage::StorageHelper;

openraft/src/storage/mod.rs

-7
Original file line numberDiff line numberDiff line change
@@ -340,10 +340,3 @@ where C: RaftTypeConfig
340340
&mut self,
341341
) -> Result<Option<Snapshot<C::NodeId, C::Node, Self::SnapshotData>>, StorageError<C::NodeId>>;
342342
}
343-
344-
/// APIs for debugging a store.
345-
#[async_trait]
346-
pub trait RaftStorageDebug<SM> {
347-
/// Get a handle to the state machine for testing purposes.
348-
async fn get_state_machine(&mut self) -> SM;
349-
}

openraft/src/store_ext.rs

-12
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use crate::storage::Snapshot;
2020
use crate::DefensiveCheck;
2121
use crate::LogId;
2222
use crate::RaftStorage;
23-
use crate::RaftStorageDebug;
2423
use crate::RaftTypeConfig;
2524
use crate::SnapshotMeta;
2625
use crate::StorageError;
@@ -144,17 +143,6 @@ where
144143
{
145144
}
146145

147-
#[async_trait]
148-
impl<C, T, SM> RaftStorageDebug<SM> for StoreExt<C, T>
149-
where
150-
T: RaftStorage<C> + RaftStorageDebug<SM>,
151-
C: RaftTypeConfig,
152-
{
153-
async fn get_state_machine(&mut self) -> SM {
154-
self.inner().get_state_machine().await
155-
}
156-
}
157-
158146
#[async_trait]
159147
impl<C: RaftTypeConfig, T: RaftStorage<C>> RaftStorage<C> for StoreExt<C, T>
160148
where

tests/tests/metrics/t20_metrics_state_machine_consistency.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use std::time::Duration;
44
use anyhow::Result;
55
use maplit::btreeset;
66
use openraft::Config;
7-
use openraft::RaftStorageDebug;
87
use openraft::ServerState;
98

109
use crate::fixtures::init_default_ut_tracing;
@@ -57,7 +56,7 @@ async fn metrics_state_machine_consistency() -> Result<()> {
5756
log_index += 1;
5857
for node_id in 0..2 {
5958
router.wait_for_log(&btreeset![node_id], Some(log_index), None, "write one log").await?;
60-
let mut sto = router.get_storage_handle(&node_id)?;
59+
let sto = router.get_storage_handle(&node_id)?;
6160
assert!(sto.get_state_machine().await.client_status.get("foo").is_some());
6261
}
6362

0 commit comments

Comments
 (0)