Skip to content

Commit 72b0224

Browse files
committed
change rename replicate_to_state_machine to apply_to_state_machine
1 parent 5d0c0b2 commit 72b0224

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

async-raft/src/core/append_entries.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ impl<D: AppData, R: AppDataResponse, N: RaftNetwork<D>, S: RaftStorage<D, R>> Ra
264264
// Create a new vector of references to the entries data ... might have to change this
265265
// interface a bit before 1.0.
266266
let entries_refs: Vec<_> = entries.iter().collect();
267-
storage.replicate_to_state_machine(&entries_refs).await?;
267+
storage.apply_to_state_machine(&entries_refs).await?;
268268
Ok(last_log_id)
269269
}
270270
.instrument(tracing::debug_span!("spawn")),
@@ -301,7 +301,7 @@ impl<D: AppData, R: AppDataResponse, N: RaftNetwork<D>, S: RaftStorage<D, R>> Ra
301301
if data_entries.is_empty() {
302302
return Ok(new_last_applied);
303303
}
304-
storage.replicate_to_state_machine(&data_entries).await?;
304+
storage.apply_to_state_machine(&data_entries).await?;
305305
Ok(new_last_applied)
306306
}
307307
.instrument(tracing::debug_span!("spawn-init-replicate-to-sm")),

async-raft/src/core/client.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ impl<'a, D: AppData, R: AppDataResponse, N: RaftNetwork<D>, S: RaftStorage<D, R>
430430
if !data_entries.is_empty() {
431431
self.core
432432
.storage
433-
.replicate_to_state_machine(&data_entries)
433+
.apply_to_state_machine(&data_entries)
434434
.await
435435
.map_err(|err| self.core.map_fatal_storage_error(err))?;
436436
}
@@ -445,7 +445,7 @@ impl<'a, D: AppData, R: AppDataResponse, N: RaftNetwork<D>, S: RaftStorage<D, R>
445445
}
446446
}
447447
// Apply this entry to the state machine and return its data response.
448-
let res = self.core.storage.replicate_to_state_machine(&[entry]).await.map_err(|err| {
448+
let res = self.core.storage.apply_to_state_machine(&[entry]).await.map_err(|err| {
449449
if err.downcast_ref::<S::ShutdownError>().is_some() {
450450
// If this is an instance of the storage impl's shutdown error, then trigger shutdown.
451451
self.core.map_fatal_storage_error(err)

async-raft/src/storage.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ where
189189
/// `Raft.client_write` call point.
190190
///
191191
/// Errors returned from this method will cause Raft to go into shutdown.
192-
async fn replicate_to_state_machine(&self, entries: &[&Entry<D>]) -> Result<Vec<R>>;
192+
async fn apply_to_state_machine(&self, entries: &[&Entry<D>]) -> Result<Vec<R>>;
193193

194194
/// Perform log compaction, returning a handle to the generated snapshot.
195195
///

memstore/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ impl RaftStorage<ClientRequest, ClientResponse> for MemStore {
282282
}
283283

284284
#[tracing::instrument(level = "trace", skip(self, entries))]
285-
async fn replicate_to_state_machine(&self, entries: &[&Entry<ClientRequest>]) -> Result<Vec<ClientResponse>> {
285+
async fn apply_to_state_machine(&self, entries: &[&Entry<ClientRequest>]) -> Result<Vec<ClientResponse>> {
286286
let mut sm = self.sm.write().await;
287287
let mut res = Vec::with_capacity(entries.len());
288288

memstore/src/test.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ async fn test_apply_entry_to_state_machine() -> Result<()> {
270270
},
271271
}),
272272
};
273-
store.replicate_to_state_machine(&[&entry]).await?;
273+
store.apply_to_state_machine(&[&entry]).await?;
274274
let sm = store.get_state_machine().await;
275275

276276
assert_eq!(
@@ -326,7 +326,7 @@ async fn test_replicate_to_state_machine() -> Result<()> {
326326
})
327327
.collect::<Vec<_>>();
328328

329-
store.replicate_to_state_machine(&entries.iter().collect::<Vec<_>>()).await?;
329+
store.apply_to_state_machine(&entries.iter().collect::<Vec<_>>()).await?;
330330
let sm = store.get_state_machine().await;
331331

332332
assert_eq!(

0 commit comments

Comments
 (0)