Skip to content

Commit

Permalink
Cleanup imports
Browse files Browse the repository at this point in the history
  • Loading branch information
jopemachine committed Jan 12, 2024
1 parent a2c1071 commit 893ea5a
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 33 deletions.
3 changes: 1 addition & 2 deletions binding/python/src/bindings/raft_facade.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
37 changes: 18 additions & 19 deletions raftify/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion raftify/src/raft_node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions raftify/src/request_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<LogEntry: AbstractLogEntry, FSM: AbstractStateMachine> {
IsLeader {
chan: Sender<LocalResponseMsg<LogEntry, FSM>>,
Expand Down Expand Up @@ -100,8 +100,8 @@ pub enum LocalRequestMsg<LogEntry: AbstractLogEntry, FSM: AbstractStateMachine>
},
}

// 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 },
}
Expand Down
14 changes: 9 additions & 5 deletions raftify/src/storage/heed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<()>;
Expand Down
6 changes: 4 additions & 2 deletions raftify/src/storage/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PathBuf> {
let log_dir_path = format!("{}/node-{}", log_dir, node_id);
Expand Down

0 comments on commit 893ea5a

Please sign in to comment.