|
|
@@ -1,42 +1,16 @@
|
|
|
-use parking_lot::Mutex;
|
|
|
+#[derive(Default)]
|
|
|
+pub struct DoNothingPersister {}
|
|
|
|
|
|
-#[derive(Clone)]
|
|
|
-pub struct State {
|
|
|
- pub bytes: bytes::Bytes,
|
|
|
- pub snapshot: Vec<u8>,
|
|
|
-}
|
|
|
-
|
|
|
-pub struct Persister {
|
|
|
- state: Mutex<State>,
|
|
|
-}
|
|
|
-
|
|
|
-impl Persister {
|
|
|
- pub fn new() -> Self {
|
|
|
- Self {
|
|
|
- state: Mutex::new(State {
|
|
|
- bytes: bytes::Bytes::new(),
|
|
|
- snapshot: vec![],
|
|
|
- }),
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-impl ruaft::Persister for Persister {
|
|
|
+impl ruaft::Persister for DoNothingPersister {
|
|
|
fn read_state(&self) -> bytes::Bytes {
|
|
|
- self.state.lock().bytes.clone()
|
|
|
+ bytes::Bytes::new()
|
|
|
}
|
|
|
|
|
|
- fn save_state(&self, data: bytes::Bytes) {
|
|
|
- self.state.lock().bytes = data;
|
|
|
- }
|
|
|
+ fn save_state(&self, _data: bytes::Bytes) {}
|
|
|
|
|
|
fn state_size(&self) -> usize {
|
|
|
- self.state.lock().bytes.len()
|
|
|
+ 0
|
|
|
}
|
|
|
|
|
|
- fn save_snapshot_and_state(&self, state: bytes::Bytes, snapshot: &[u8]) {
|
|
|
- let mut this = self.state.lock();
|
|
|
- this.bytes = state;
|
|
|
- this.snapshot = snapshot.to_vec();
|
|
|
- }
|
|
|
+ fn save_snapshot_and_state(&self, _state: bytes::Bytes, _snapshot: &[u8]) {}
|
|
|
}
|