From 893ea5a68081c86d07a7b161f31d980910363184 Mon Sep 17 00:00:00 2001 From: Gyubong Date: Fri, 12 Jan 2024 17:33:25 +0900 Subject: [PATCH] Cleanup imports --- binding/python/src/bindings/raft_facade.rs | 3 +- raftify/src/lib.rs | 37 +++++++++++----------- raftify/src/raft_node/mod.rs | 2 +- raftify/src/request_message.rs | 8 ++--- raftify/src/storage/heed.rs | 14 +++++--- raftify/src/storage/utils.rs | 6 ++-- 6 files changed, 37 insertions(+), 33 deletions(-) diff --git a/binding/python/src/bindings/raft_facade.rs b/binding/python/src/bindings/raft_facade.rs index ca0b3853..f94e70c7 100644 --- a/binding/python/src/bindings/raft_facade.rs +++ b/binding/python/src/bindings/raft_facade.rs @@ -1,8 +1,7 @@ -use std::sync::Arc; - use pyo3::{exceptions::PyException, prelude::*, types::PyString}; use pyo3_asyncio::tokio::future_into_py; use raftify::Raft; +use std::sync::Arc; use super::{ cluster_join_ticket::PyClusterJoinTicket, diff --git a/raftify/src/lib.rs b/raftify/src/lib.rs index b84e1159..6d2b3688 100644 --- a/raftify/src/lib.rs +++ b/raftify/src/lib.rs @@ -21,26 +21,25 @@ mod utils; pub mod cli; pub mod raft_service; -pub use async_trait::async_trait; -pub use formatter::CustomFormatter; -pub use jopemachine_raft as raft; -pub use raft::Config as RaftConfig; -pub use tonic; -pub use tonic::transport::Channel; +pub use { + async_trait::async_trait, formatter::CustomFormatter, jopemachine_raft as raft, + raft::Config as RaftConfig, tonic, tonic::transport::Channel, +}; -pub use crate::config::Config; -pub use crate::error::{Error, Result}; -pub use crate::follower_role::FollowerRole; -pub use crate::log_entry::AbstractLogEntry; -pub use crate::peer::Peer; -pub use crate::peers::Peers; -pub use crate::raft_client::create_client; -pub use crate::raft_facade::ClusterJoinTicket; -pub use crate::raft_facade::Raft; -pub use crate::raft_node::RaftNode; -pub use crate::raft_service::raft_service_client::RaftServiceClient; -pub use crate::state_machine::AbstractStateMachine; -pub use crate::storage::heed::{HeedStorage, LogStore}; +pub use crate::{ + config::Config, + error::{Error, Result}, + follower_role::FollowerRole, + log_entry::AbstractLogEntry, + peer::Peer, + peers::Peers, + raft_client::create_client, + raft_facade::{ClusterJoinTicket, Raft}, + raft_node::RaftNode, + raft_service::raft_service_client::RaftServiceClient, + state_machine::AbstractStateMachine, + storage::heed::{HeedStorage, LogStore}, +}; // pub(crate) use utils::get_filesize; // pub(crate) use utils::is_near_zero; diff --git a/raftify/src/raft_node/mod.rs b/raftify/src/raft_node/mod.rs index a60a38b1..bcdff2ef 100644 --- a/raftify/src/raft_node/mod.rs +++ b/raftify/src/raft_node/mod.rs @@ -3,7 +3,7 @@ mod response_sender; pub mod utils; use bincode::{deserialize, serialize}; -use jopemachine_raft::logger::{Logger, Slogger}; +use jopemachine_raft::logger::Logger; use prost::Message as PMessage; use std::{ collections::HashMap, diff --git a/raftify/src/request_message.rs b/raftify/src/request_message.rs index 17f02aba..0c7cf9e7 100644 --- a/raftify/src/request_message.rs +++ b/raftify/src/request_message.rs @@ -6,7 +6,7 @@ use super::{ }; use crate::raft::eraftpb::{ConfChangeV2, Message as RaftMessage}; -// Request type processed through network calls (grpc) +/// Request type processed through network calls (gRPC) pub enum ServerRequestMsg { MemberBootstrapReady { node_id: u64, @@ -37,7 +37,7 @@ pub enum ServerRequestMsg { }, } -// Request type used for communication (method calls) between RaftFacade and RaftNode +/// Request type used for communication (method calls) between RaftFacade and RaftNode pub enum LocalRequestMsg { IsLeader { chan: Sender>, @@ -100,8 +100,8 @@ pub enum LocalRequestMsg }, } -// Request type sent from a RaftNode to itself (RaftNode). -// Used for accessing the RaftNode from a future created by RaftNode asynchronous methods +/// Request type sent from a RaftNode to itself (RaftNode). +/// Used for accessing the RaftNode from a future created by RaftNode asynchronous methods pub enum SelfMessage { ReportUnreachable { node_id: u64 }, } diff --git a/raftify/src/storage/heed.rs b/raftify/src/storage/heed.rs index 54d1d055..f7db5c8e 100644 --- a/raftify/src/storage/heed.rs +++ b/raftify/src/storage/heed.rs @@ -15,11 +15,15 @@ use std::{ sync::Arc, }; -use super::constant::{CONF_STATE_KEY, HARD_STATE_KEY, LAST_INDEX_KEY, SNAPSHOT_KEY}; -use super::utils::{append_to_json_file, format_entry_key_string}; -use crate::config::Config; -use crate::error::Result; -use crate::raft::{self, prelude::*, GetEntriesContext}; +use super::{ + constant::{CONF_STATE_KEY, HARD_STATE_KEY, LAST_INDEX_KEY, SNAPSHOT_KEY}, + utils::{append_to_json_file, format_entry_key_string}, +}; +use crate::{ + config::Config, + error::Result, + raft::{self, prelude::*, GetEntriesContext}, +}; pub trait LogStore: Storage { fn append(&mut self, entries: &[Entry]) -> Result<()>; diff --git a/raftify/src/storage/utils.rs b/raftify/src/storage/utils.rs index 04e12e37..baedd175 100644 --- a/raftify/src/storage/utils.rs +++ b/raftify/src/storage/utils.rs @@ -8,8 +8,10 @@ use std::{ }; use super::constant::ENTRY_KEY_LENGTH; -use crate::raft::{eraftpb::Entry, formatter::CUSTOM_FORMATTER}; -use crate::Result; +use crate::{ + raft::{eraftpb::Entry, formatter::CUSTOM_FORMATTER}, + Result, +}; pub fn get_storage_path(log_dir: &str, node_id: u64) -> Result { let log_dir_path = format!("{}/node-{}", log_dir, node_id);