Skip to content

Commit

Permalink
change rename replicate_to_state_machine to apply_to_state_machine
Browse files Browse the repository at this point in the history
  • Loading branch information
drmingdrmer committed Aug 24, 2021
1 parent 5d0c0b2 commit 72b0224
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions async-raft/src/core/append_entries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ impl<D: AppData, R: AppDataResponse, N: RaftNetwork<D>, S: RaftStorage<D, R>> Ra
// Create a new vector of references to the entries data ... might have to change this
// interface a bit before 1.0.
let entries_refs: Vec<_> = entries.iter().collect();
storage.replicate_to_state_machine(&entries_refs).await?;
storage.apply_to_state_machine(&entries_refs).await?;
Ok(last_log_id)
}
.instrument(tracing::debug_span!("spawn")),
Expand Down Expand Up @@ -301,7 +301,7 @@ impl<D: AppData, R: AppDataResponse, N: RaftNetwork<D>, S: RaftStorage<D, R>> Ra
if data_entries.is_empty() {
return Ok(new_last_applied);
}
storage.replicate_to_state_machine(&data_entries).await?;
storage.apply_to_state_machine(&data_entries).await?;
Ok(new_last_applied)
}
.instrument(tracing::debug_span!("spawn-init-replicate-to-sm")),
Expand Down
4 changes: 2 additions & 2 deletions async-raft/src/core/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ impl<'a, D: AppData, R: AppDataResponse, N: RaftNetwork<D>, S: RaftStorage<D, R>
if !data_entries.is_empty() {
self.core
.storage
.replicate_to_state_machine(&data_entries)
.apply_to_state_machine(&data_entries)
.await
.map_err(|err| self.core.map_fatal_storage_error(err))?;
}
Expand All @@ -445,7 +445,7 @@ impl<'a, D: AppData, R: AppDataResponse, N: RaftNetwork<D>, S: RaftStorage<D, R>
}
}
// Apply this entry to the state machine and return its data response.
let res = self.core.storage.replicate_to_state_machine(&[entry]).await.map_err(|err| {
let res = self.core.storage.apply_to_state_machine(&[entry]).await.map_err(|err| {
if err.downcast_ref::<S::ShutdownError>().is_some() {
// If this is an instance of the storage impl's shutdown error, then trigger shutdown.
self.core.map_fatal_storage_error(err)
Expand Down
2 changes: 1 addition & 1 deletion async-raft/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ where
/// `Raft.client_write` call point.
///
/// Errors returned from this method will cause Raft to go into shutdown.
async fn replicate_to_state_machine(&self, entries: &[&Entry<D>]) -> Result<Vec<R>>;
async fn apply_to_state_machine(&self, entries: &[&Entry<D>]) -> Result<Vec<R>>;

/// Perform log compaction, returning a handle to the generated snapshot.
///
Expand Down
2 changes: 1 addition & 1 deletion memstore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ impl RaftStorage<ClientRequest, ClientResponse> for MemStore {
}

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

Expand Down
4 changes: 2 additions & 2 deletions memstore/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ async fn test_apply_entry_to_state_machine() -> Result<()> {
},
}),
};
store.replicate_to_state_machine(&[&entry]).await?;
store.apply_to_state_machine(&[&entry]).await?;
let sm = store.get_state_machine().await;

assert_eq!(
Expand Down Expand Up @@ -326,7 +326,7 @@ async fn test_replicate_to_state_machine() -> Result<()> {
})
.collect::<Vec<_>>();

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

assert_eq!(
Expand Down

0 comments on commit 72b0224

Please sign in to comment.