Skip to content

Commit

Permalink
change: rename RaftStorage::create_snapshot() to RaftStorage::begin_r…
Browse files Browse the repository at this point in the history
…eceiving_snapshot
  • Loading branch information
drmingdrmer committed Aug 23, 2021
1 parent fea63b2 commit fabf3e7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion async-raft/src/core/install_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ impl<D: AppData, R: AppDataResponse, N: RaftNetwork<D>, S: RaftStorage<D, R>> Ra
}

// Create a new snapshot and begin writing its contents.
let mut snapshot = self.storage.create_snapshot().await.map_err(|err| self.map_fatal_storage_error(err))?;
let mut snapshot =
self.storage.begin_receiving_snapshot().await.map_err(|err| self.map_fatal_storage_error(err))?;
snapshot.as_mut().write_all(&req.data).await?;

// If this was a small snapshot, and it is already done, then finish up.
Expand Down
4 changes: 3 additions & 1 deletion async-raft/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,14 @@ where

/// Create a new blank snapshot, returning a writable handle to the snapshot object.
///
/// Raft will use this handle to receive snapshot data.
///
/// ### implementation guide
/// See the [storage chapter of the guide](https://async-raft.github.io/async-raft/storage.html)
/// for details on log compaction / snapshotting.
///
/// Errors returned from this method will cause Raft to go into shutdown.
async fn create_snapshot(&self) -> Result<Box<Self::SnapshotData>>;
async fn begin_receiving_snapshot(&self) -> Result<Box<Self::SnapshotData>>;

/// Finalize the installation of a snapshot which has finished streaming from the cluster leader.
///
Expand Down
2 changes: 1 addition & 1 deletion memstore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ impl RaftStorage<ClientRequest, ClientResponse> for MemStore {
}

#[tracing::instrument(level = "trace", skip(self))]
async fn create_snapshot(&self) -> Result<Box<Self::SnapshotData>> {
async fn begin_receiving_snapshot(&self) -> Result<Box<Self::SnapshotData>> {
Ok(Box::new(Cursor::new(Vec::new())))
}

Expand Down

0 comments on commit fabf3e7

Please sign in to comment.