Skip to content

Commit d396eda

Browse files
committed
Refactor: rename WriteResult to ClientWriteResult
`WriteResult` is public but is sealed behind a private mod, thus this is not a breaking change.
1 parent 45d5a94 commit d396eda

File tree

7 files changed

+16
-16
lines changed

7 files changed

+16
-16
lines changed

openraft/src/raft/impl_raft_blocking_write.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use maplit::btreemap;
77
use crate::core::raft_msg::RaftMsg;
88
use crate::error::ClientWriteError;
99
use crate::error::RaftError;
10-
use crate::raft::message::WriteResult;
10+
use crate::raft::message::ClientWriteResult;
1111
use crate::raft::responder::OneshotResponder;
1212
use crate::raft::ClientWriteResponse;
1313
use crate::summary::MessageSummary;
@@ -169,7 +169,7 @@ where C: RaftTypeConfig<Responder = OneshotResponder<C>>
169169
}
170170
}
171171

172-
fn oneshot_channel<C>() -> (OneshotResponder<C>, OneshotReceiverOf<C, WriteResult<C>>)
172+
fn oneshot_channel<C>() -> (OneshotResponder<C>, OneshotReceiverOf<C, ClientWriteResult<C>>)
173173
where C: RaftTypeConfig {
174174
let (tx, rx) = C::AsyncRuntime::oneshot();
175175

openraft/src/raft/message/client_write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::MessageSummary;
1111
use crate::RaftTypeConfig;
1212

1313
/// The result of a write request to Raft.
14-
pub type WriteResult<C> = Result<ClientWriteResponse<C>, ClientWriteError<NodeIdOf<C>, NodeOf<C>>>;
14+
pub type ClientWriteResult<C> = Result<ClientWriteResponse<C>, ClientWriteError<NodeIdOf<C>, NodeOf<C>>>;
1515

1616
/// The response to a client-request.
1717
#[cfg_attr(

openraft/src/raft/message/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ mod client_write;
1212
pub use append_entries::AppendEntriesRequest;
1313
pub use append_entries::AppendEntriesResponse;
1414
pub use client_write::ClientWriteResponse;
15-
pub use client_write::WriteResult;
15+
pub use client_write::ClientWriteResult;
1616
pub use install_snapshot::InstallSnapshotRequest;
1717
pub use install_snapshot::InstallSnapshotResponse;
1818
pub use install_snapshot::SnapshotResponse;

openraft/src/raft/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ use core_state::CoreState;
2626
pub use message::AppendEntriesRequest;
2727
pub use message::AppendEntriesResponse;
2828
pub use message::ClientWriteResponse;
29+
pub use message::ClientWriteResult;
2930
pub use message::InstallSnapshotRequest;
3031
pub use message::InstallSnapshotResponse;
3132
pub use message::SnapshotResponse;
3233
pub use message::VoteRequest;
3334
pub use message::VoteResponse;
34-
pub use message::WriteResult;
3535
use tokio::sync::mpsc;
3636
use tokio::sync::watch;
3737
use tokio::sync::Mutex;
@@ -644,12 +644,12 @@ where C: RaftTypeConfig
644644
app_data: C::D,
645645
) -> Result<ClientWriteResponse<C>, RaftError<C::NodeId, ClientWriteError<C::NodeId, C::Node>>>
646646
where
647-
ResponderReceiverOf<C>: Future<Output = Result<WriteResult<C>, E>>,
647+
ResponderReceiverOf<C>: Future<Output = Result<ClientWriteResult<C>, E>>,
648648
E: Error + OptionalSend,
649649
{
650650
let rx = self.client_write_ff(app_data).await?;
651651

652-
let res: WriteResult<C> = self.inner.recv_msg(rx).await?;
652+
let res: ClientWriteResult<C> = self.inner.recv_msg(rx).await?;
653653

654654
let client_write_response = res.map_err(RaftError::APIError)?;
655655
Ok(client_write_response)

openraft/src/raft/responder/impls.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::async_runtime::AsyncOneshotSendExt;
2-
use crate::raft::message::WriteResult;
2+
use crate::raft::message::ClientWriteResult;
33
use crate::raft::responder::Responder;
44
use crate::type_config::alias::AsyncRuntimeOf;
55
use crate::type_config::alias::OneshotReceiverOf;
@@ -15,30 +15,30 @@ use crate::RaftTypeConfig;
1515
pub struct OneshotResponder<C>
1616
where C: RaftTypeConfig
1717
{
18-
tx: OneshotSenderOf<C, WriteResult<C>>,
18+
tx: OneshotSenderOf<C, ClientWriteResult<C>>,
1919
}
2020

2121
impl<C> OneshotResponder<C>
2222
where C: RaftTypeConfig
2323
{
2424
/// Create a new instance from a [`AsyncRuntime::OneshotSender`].
25-
pub fn new(tx: OneshotSenderOf<C, WriteResult<C>>) -> Self {
25+
pub fn new(tx: OneshotSenderOf<C, ClientWriteResult<C>>) -> Self {
2626
Self { tx }
2727
}
2828
}
2929

3030
impl<C> Responder<C> for OneshotResponder<C>
3131
where C: RaftTypeConfig
3232
{
33-
type Receiver = OneshotReceiverOf<C, WriteResult<C>>;
33+
type Receiver = OneshotReceiverOf<C, ClientWriteResult<C>>;
3434

3535
fn from_app_data(app_data: C::D) -> (C::D, Self, Self::Receiver)
3636
where Self: Sized {
3737
let (tx, rx) = AsyncRuntimeOf::<C>::oneshot();
3838
(app_data, Self { tx }, rx)
3939
}
4040

41-
fn send(self, res: WriteResult<C>) {
41+
fn send(self, res: ClientWriteResult<C>) {
4242
let res = self.tx.send(res);
4343

4444
if res.is_ok() {

openraft/src/raft/responder/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
pub(crate) mod impls;
44
pub use impls::OneshotResponder;
55

6-
use crate::raft::message::WriteResult;
6+
use crate::raft::message::ClientWriteResult;
77
use crate::OptionalSend;
88
use crate::RaftTypeConfig;
99

@@ -12,7 +12,7 @@ use crate::RaftTypeConfig;
1212
///
1313
/// It is created for each request [`AppData`], and is sent to `RaftCore`.
1414
/// Once the request is completed,
15-
/// the `RaftCore` send the result [`WriteResult`] via it.
15+
/// the `RaftCore` send the result [`ClientWriteResult`] via it.
1616
/// The implementation of the trait then forward the response to application.
1717
/// There could optionally be a receiver to wait for the response.
1818
///
@@ -35,5 +35,5 @@ where C: RaftTypeConfig
3535
/// Send result when the request has been completed.
3636
///
3737
/// This method is called by the `RaftCore` once the request has been applied to state machine.
38-
fn send(self, result: WriteResult<C>);
38+
fn send(self, result: ClientWriteResult<C>);
3939
}

openraft/src/type_config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub trait RaftTypeConfig:
7979
/// some application defined channel.
8080
///
8181
/// [`Raft::client_write`]: `crate::raft::Raft::client_write`
82-
/// [`WriteResult`]: `crate::raft::message::WriteResult`
82+
/// [`WriteResult`]: `crate::raft::message::ClientWriteResult`
8383
type Responder: Responder<Self>;
8484
}
8585

0 commit comments

Comments
 (0)