Skip to content

Commit

Permalink
Rollback impl AssertSend (#542)
Browse files Browse the repository at this point in the history
Signed-off-by: tison <[email protected]>
  • Loading branch information
tisonkun authored Apr 14, 2024
1 parent a76fb6e commit 668bed2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 3 additions & 1 deletion src/raft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,9 @@ impl<T: Storage> DerefMut for Raft<T> {
}
}

impl<T: Storage + Send> Raft<T> {}
#[allow(dead_code)] // ensure Raft<T> is always Send
trait AssertSend: Send {}
impl<T: Storage + Send> AssertSend for Raft<T> {}

fn new_message(to: u64, field_type: MessageType, from: Option<u64>) -> Message {
let mut m = Message::default();
Expand Down
18 changes: 8 additions & 10 deletions src/raft_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,20 @@
// limitations under the License.

use std::cmp;
use std::fmt::{Display, Formatter};

use slog::warn;
use slog::Logger;
use slog::{debug, info, trace};

use crate::config::Config;
use crate::eraftpb::{Entry, Snapshot};
use crate::errors::{Error, Result, StorageError};
use crate::log_unstable::Unstable;
use crate::storage::{GetEntriesContext, GetEntriesFor, Storage};
use crate::util;

pub use crate::util::NO_LIMIT;

use slog::{debug, info, trace};

/// Raft log implementation
pub struct RaftLog<T: Storage> {
/// Contains all stable entries since the last snapshot.
Expand Down Expand Up @@ -69,12 +68,10 @@ pub struct RaftLog<T: Storage> {
pub max_apply_unpersisted_log_limit: u64,
}

impl<T> ToString for RaftLog<T>
where
T: Storage,
{
fn to_string(&self) -> String {
format!(
impl<T: Storage> Display for RaftLog<T> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(
f,
"committed={}, persisted={}, applied={}, unstable.offset={}, unstable.entries.len()={}",
self.committed,
self.persisted,
Expand Down Expand Up @@ -728,14 +725,15 @@ mod test {
panic::{self, AssertUnwindSafe},
};

use protobuf::Message as PbMessage;

use crate::config::Config;
use crate::default_logger;
use crate::eraftpb;
use crate::errors::{Error, StorageError};
use crate::raft_log::{self, RaftLog};
use crate::storage::{GetEntriesContext, MemStorage};
use crate::NO_LIMIT;
use protobuf::Message as PbMessage;

fn new_entry(index: u64, term: u64) -> eraftpb::Entry {
let mut e = eraftpb::Entry::default();
Expand Down

0 comments on commit 668bed2

Please sign in to comment.