Skip to content

Commit

Permalink
update comment
Browse files Browse the repository at this point in the history
  • Loading branch information
BusyJay committed Sep 18, 2016
1 parent 032ba77 commit f4bfe32
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/server/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ use util::transport::SendCh;


pub trait RaftStoreRouter: Send + Clone {
/// Send StoreMsg.
fn try_send(&self, msg: StoreMsg) -> RaftStoreResult<()>;

/// Send StoreMsg, retry if failed. Try times may vary from implementation.
fn send(&self, msg: StoreMsg) -> RaftStoreResult<()>;

/// Send StoreMsg.
fn try_send(&self, msg: StoreMsg) -> RaftStoreResult<()>;

// Send RaftMessage to local store.
fn send_raft_msg(&self, msg: RaftMessage) -> RaftStoreResult<()> {
self.try_send(StoreMsg::RaftMessage(msg))
Expand Down Expand Up @@ -129,11 +129,11 @@ impl Transport for ServerTransport {
pub struct MockRaftStoreRouter;

impl RaftStoreRouter for MockRaftStoreRouter {
fn try_send(&self, _: StoreMsg) -> RaftStoreResult<()> {
fn send(&self, _: StoreMsg) -> RaftStoreResult<()> {
unimplemented!();
}

fn send(&self, _: StoreMsg) -> RaftStoreResult<()> {
fn try_send(&self, _: StoreMsg) -> RaftStoreResult<()> {
unimplemented!();
}
}
8 changes: 4 additions & 4 deletions src/util/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ impl<T: Debug> SendCh<T> {
SendCh { ch: ch }
}

pub fn try_send(&self, t: T) -> Result<(), Error> {
self.send_with_try_times(t, 1)
}

/// Try send t with default try times.
pub fn send(&self, t: T) -> Result<(), Error> {
self.send_with_try_times(t, MAX_SEND_RETRY_CNT)
}

pub fn try_send(&self, t: T) -> Result<(), Error> {
self.send_with_try_times(t, 1)
}

fn send_with_try_times(&self, mut t: T, mut try_times: usize) -> Result<(), Error> {
loop {
t = match self.ch.send(t) {
Expand Down
4 changes: 2 additions & 2 deletions tests/raftstore/transport_simulate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ impl<C: Channel<RaftMessage>> Transport for SimulateTransport<RaftMessage, C> {
}

impl<C: Channel<StoreMsg>> RaftStoreRouter for SimulateTransport<StoreMsg, C> {
fn try_send(&self, m: StoreMsg) -> Result<()> {
fn send(&self, m: StoreMsg) -> Result<()> {
Channel::send(self, m)
}

fn send(&self, m: StoreMsg) -> Result<()> {
fn try_send(&self, m: StoreMsg) -> Result<()> {
Channel::send(self, m)
}
}
Expand Down

0 comments on commit f4bfe32

Please sign in to comment.