diff --git a/.travis.yml b/.travis.yml index c0703a0..cbeef25 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,7 @@ before_script: script: - cargo test - cargo clippy + - cd raftlog_simu; cargo clippy --all-targets matrix: allow_failures: diff --git a/raftlog_simu/Cargo.toml b/raftlog_simu/Cargo.toml index 3bacd4e..9c7c9cb 100644 --- a/raftlog_simu/Cargo.toml +++ b/raftlog_simu/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "raftlog_simu" version = "0.1.0" authors = ["The FrugalOS Developers"] diff --git a/raftlog_simu/src/io/configs.rs b/raftlog_simu/src/io/configs.rs index 589eabc..a341f30 100644 --- a/raftlog_simu/src/io/configs.rs +++ b/raftlog_simu/src/io/configs.rs @@ -1,5 +1,5 @@ //! I/O関連の構成設定を集めたモジュール. -use types::{LogicalDuration, Probability, Range}; +use crate::types::{LogicalDuration, Probability, Range}; /// `Timer`用の構成設定. #[derive(Debug, Clone, Serialize, Deserialize)] diff --git a/raftlog_simu/src/io/deterministic.rs b/raftlog_simu/src/io/deterministic.rs index 3dc7104..370d758 100644 --- a/raftlog_simu/src/io/deterministic.rs +++ b/raftlog_simu/src/io/deterministic.rs @@ -4,11 +4,11 @@ use raftlog::message::Message; use raftlog::node::NodeId; use raftlog::Io; -use io::configs::{ChannelConfig, StorageConfig, TimerConfig}; -use io::futures; -use io::{MessageBroker, Storage, Timer}; -use types::SharedRng; -use Result; +use crate::io::configs::{ChannelConfig, StorageConfig, TimerConfig}; +use crate::io::futures; +use crate::io::{MessageBroker, Storage, Timer}; +use crate::types::SharedRng; +use crate::Result; /// `DeterministicIo`のビルダ. pub struct DeterministicIoBuilder { diff --git a/raftlog_simu/src/io/futures.rs b/raftlog_simu/src/io/futures.rs index 9f507e8..e9cdeec 100644 --- a/raftlog_simu/src/io/futures.rs +++ b/raftlog_simu/src/io/futures.rs @@ -3,8 +3,8 @@ use futures::{Async, Future, Poll}; use raftlog::election::Ballot; use raftlog::log::Log; -use types::LogicalDuration; -use Error; +use crate::types::LogicalDuration; +use crate::Error; pub type Timeout = DelayedResult<(), Error>; pub type SaveBallot = DelayedResult<(), Error>; diff --git a/raftlog_simu/src/io/storage.rs b/raftlog_simu/src/io/storage.rs index 5bdcfd9..c08b4cc 100644 --- a/raftlog_simu/src/io/storage.rs +++ b/raftlog_simu/src/io/storage.rs @@ -6,10 +6,10 @@ use raftlog::log::{Log, LogIndex, LogPosition, LogPrefix, LogSuffix}; use raftlog::node::NodeId; use trackable::error::ErrorKindExt; -use io::configs::StorageConfig; -use io::futures::{DelayedResult, LoadBallot, LoadLog, SaveBallot, SaveLog}; -use types::SharedRng; -use {ErrorKind, Result}; +use crate::io::configs::StorageConfig; +use crate::io::futures::{DelayedResult, LoadBallot, LoadLog, SaveBallot, SaveLog}; +use crate::types::SharedRng; +use crate::{ErrorKind, Result}; /// シミュレータ用のストレージ実装. /// diff --git a/raftlog_simu/src/io/timer.rs b/raftlog_simu/src/io/timer.rs index 4c1e403..9a48dd7 100644 --- a/raftlog_simu/src/io/timer.rs +++ b/raftlog_simu/src/io/timer.rs @@ -1,9 +1,9 @@ use raftlog::election::Role; use rand::Rng; -use io::configs::TimerConfig; -use io::futures::{DelayedResult, Timeout}; -use types::SharedRng; +use crate::io::configs::TimerConfig; +use crate::io::futures::{DelayedResult, Timeout}; +use crate::types::SharedRng; /// シミュレータ用のタイマー実装. /// diff --git a/raftlog_simu/src/io/transport.rs b/raftlog_simu/src/io/transport.rs index 4cd3c8b..db0d2c6 100644 --- a/raftlog_simu/src/io/transport.rs +++ b/raftlog_simu/src/io/transport.rs @@ -5,9 +5,9 @@ use std::cmp::Ordering; use std::collections::{BinaryHeap, HashMap}; use std::rc::Rc; -use io::configs::ChannelConfig; -use types::SharedRng; -use Result; +use crate::io::configs::ChannelConfig; +use crate::types::SharedRng; +use crate::Result; /// シミュレータ用のRPCメッセージブローカー. /// diff --git a/raftlog_simu/src/lib.rs b/raftlog_simu/src/lib.rs index c2dfb3a..6aa7656 100644 --- a/raftlog_simu/src/lib.rs +++ b/raftlog_simu/src/lib.rs @@ -21,10 +21,10 @@ macro_rules! log { pub use raftlog::{Error, ErrorKind, Result}; #[doc(no_inline)] -pub use io::{DeterministicIo, DeterministicIoBuilder}; -pub use logger::Logger; -pub use simulator::Simulator; -pub use simulator_config::SimulatorConfig; +pub use crate::io::{DeterministicIo, DeterministicIoBuilder}; +pub use crate::logger::Logger; +pub use crate::simulator::Simulator; +pub use crate::simulator_config::SimulatorConfig; pub mod io; pub mod machine; diff --git a/raftlog_simu/src/machine.rs b/raftlog_simu/src/machine.rs index 701a377..67b9196 100644 --- a/raftlog_simu/src/machine.rs +++ b/raftlog_simu/src/machine.rs @@ -6,9 +6,9 @@ use raftlog::Event; use std::collections::BTreeMap; use trackable::error::ErrorKindExt; -use process::Process; -use types::LogicalDuration; -use {DeterministicIoBuilder, Error, ErrorKind, Logger, Result}; +use crate::process::Process; +use crate::types::LogicalDuration; +use crate::{DeterministicIoBuilder, Error, ErrorKind, Logger, Result}; /// 状態機械に発行されるコマンド(加算値). pub type Command = u64; diff --git a/raftlog_simu/src/process.rs b/raftlog_simu/src/process.rs index de6e933..2536f9b 100644 --- a/raftlog_simu/src/process.rs +++ b/raftlog_simu/src/process.rs @@ -6,12 +6,11 @@ use raftlog::log::{LogEntry, LogIndex, ProposalId}; use raftlog::message::SequenceNumber; use raftlog::node::NodeId; use raftlog::{Event, Io, ReplicatedLog}; -use serdeconv; use std::collections::VecDeque; -use machine::{Command, MachineState}; -use types::LogicalDuration; -use {DeterministicIo, Error, ErrorKind, Logger, Result}; +use crate::machine::{Command, MachineState}; +use crate::types::LogicalDuration; +use crate::{DeterministicIo, Error, ErrorKind, Logger, Result}; /// プロセス. /// @@ -188,7 +187,7 @@ impl Stream for Process { } } -#[cfg_attr(feature = "cargo-clippy", allow(large_enum_variant))] +#[allow(clippy::large_enum_variant)] enum ProcessState { Alive(Alive), Down(Down), @@ -270,7 +269,8 @@ impl Alive { ) -> Self { let metric_builder = MetricBuilder::new(); let machine = MachineState::new(); - let rlog = ReplicatedLog::new(node_id, old_members, io, &metric_builder).expect("Never fails"); + let rlog = + ReplicatedLog::new(node_id, old_members, io, &metric_builder).expect("Never fails"); Alive { logger, machine, diff --git a/raftlog_simu/src/simulator.rs b/raftlog_simu/src/simulator.rs index 6c97eea..a060ba0 100644 --- a/raftlog_simu/src/simulator.rs +++ b/raftlog_simu/src/simulator.rs @@ -4,9 +4,9 @@ use raftlog::node::NodeId; use raftlog::Event; use rand::Rng; -use machine::{MachineState, ReplicatedStateMachine}; -use types::SharedRng; -use {DeterministicIoBuilder, ErrorKind, Logger, Result, SimulatorConfig}; +use crate::machine::{MachineState, ReplicatedStateMachine}; +use crate::types::SharedRng; +use crate::{DeterministicIoBuilder, ErrorKind, Logger, Result, SimulatorConfig}; /// シミュレータ. pub struct Simulator { diff --git a/raftlog_simu/src/simulator_config.rs b/raftlog_simu/src/simulator_config.rs index 0c302f3..317a3fd 100644 --- a/raftlog_simu/src/simulator_config.rs +++ b/raftlog_simu/src/simulator_config.rs @@ -4,8 +4,8 @@ use rand::{Rng, SeedableRng, StdRng}; use std::collections::BTreeSet; use std::time::{SystemTime, UNIX_EPOCH}; -use io::IoConfig; -use types::{LogicalDuration, Probability, Range, SharedRng}; +use crate::io::IoConfig; +use crate::types::{LogicalDuration, Probability, Range, SharedRng}; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct SimulatorConfig {